You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Gul Onural <on...@nortel.com> on 2007/11/06 17:47:27 UTC
Question about embedded list of Strings
Let say I have an entity MyEntity. The MyEntity has a list of strings
inside.
@Entity
@Table(name = "TABLE_A")
public class MyEntity implements Serializable {
@Id
private int myId;
private String myName;
private List<String> myList;
}
- How does openjpa stores instances of this class in the database? For
example does it create
one table and one record for each String in the myList ?
- What would be the behavior of the openjpa if I put OneToMany
relationship annotation to the myList.
I know what it does if the type of item in the list is a user-defined
class, but I don't know what happens if the items are Strings.
- What does openjpa do if I say this.myList = null; Does this remove all
the existing records ?
Thanks
Gul
Re: Question about embedded list of Strings
Posted by Patrick Linskey <pl...@gmail.com>.
> - How does openjpa stores instances of this class in the database? For
> example does it create
> one table and one record for each String in the myList ?
You could choose to store the entire List as a serialized BLOB, or to
store it as you described above using the @PersistentCollection
annotation.
> - What would be the behavior of the openjpa if I put OneToMany
> relationship annotation to the myList.
> I know what it does if the type of item in the list is a user-defined
> class, but I don't know what happens if the items are Strings.
Good question. I'd expect an error, but I'm not sure.
> - What does openjpa do if I say this.myList = null; Does this remove all
> the existing records ?
You might want to turn on SQL debugging to take a look at what is
happening under the covers:
<property name="openjpa.Log" value="SQL=TRACE"/>
-Patrick
On Nov 6, 2007 8:47 AM, Gul Onural <on...@nortel.com> wrote:
>
>
> Let say I have an entity MyEntity. The MyEntity has a list of strings
> inside.
>
> @Entity
> @Table(name = "TABLE_A")
> public class MyEntity implements Serializable {
> @Id
> private int myId;
> private String myName;
> private List<String> myList;
> }
>
> - How does openjpa stores instances of this class in the database? For
> example does it create
> one table and one record for each String in the myList ?
>
> - What would be the behavior of the openjpa if I put OneToMany
> relationship annotation to the myList.
> I know what it does if the type of item in the list is a user-defined
> class, but I don't know what happens if the items are Strings.
>
> - What does openjpa do if I say this.myList = null; Does this remove all
> the existing records ?
>
> Thanks
>
> Gul
>
>
>
>
>
>
--
Patrick Linskey
202 669 5907