Re: How to store a string array as a string array using jpa?
Here's what I've seen (a slight addition to Fay's post in Nabble) ElementCollection may be used with Collections, or Maps. It should not be used with an array - like the original poster's example. PersistentCollection is specific to OpenJPA and may be used with an array (int[], String[]), or a Collection. PersistentMap is also specific to OpenJPA and may be used with Maps. -mike 2011/7/8 Håkon Sagehaug > Hi > > I use something like this > > @PersistentCollection >private List subEntries = new LinkedList(); > > Can also be used for String arrays. I think that PersistentCollection is > JPA > specific, but there is a annotaion called ElementCollection, from the 2.0 > spec. See this thread[1] for more info > > [1] > > http://openjpa.208410.n2.nabble.com/ElementCollection-and-PersistentCollection-td4737753.html > > > > On 8 July 2011 07:33, Suseendran.P wrote: > > > Thank you so much for ur reply..i go through the document.. > > > > First i have to say i'm very new to JPA.., > > i'm using javax.persistence related packages to annotate my class..means > > not > > using org.apache.openjpa.persistence related packages..in that document > > they > > gave JPA is not externalized can i mix these two packages in single > class.. > > > > i constructed my class like this.. > > > > @Entity > > public class Station { > > > >@Id > >@GeneratedValue(strategy = GenerationType.AUTO) > >private long id; > > > >private String[] names; > > > >// setter and getter methods > > } > > > > Now what annotation i ve to give to store this array of string names in > > single row in Mysql database.. > > > > -- > > View this message in context: > > > http://openjpa.208410.n2.nabble.com/How-to-store-a-string-array-as-a-string-array-using-jpa-tp209875p6561347.html > > Sent from the OpenJPA Users mailing list archive at Nabble.com. > > >
Re: How to store a string array as a string array using jpa?
Hi I use something like this @PersistentCollection private List subEntries = new LinkedList(); Can also be used for String arrays. I think that PersistentCollection is JPA specific, but there is a annotaion called ElementCollection, from the 2.0 spec. See this thread[1] for more info [1] http://openjpa.208410.n2.nabble.com/ElementCollection-and-PersistentCollection-td4737753.html On 8 July 2011 07:33, Suseendran.P wrote: > Thank you so much for ur reply..i go through the document.. > > First i have to say i'm very new to JPA.., > i'm using javax.persistence related packages to annotate my class..means > not > using org.apache.openjpa.persistence related packages..in that document > they > gave JPA is not externalized can i mix these two packages in single class.. > > i constructed my class like this.. > > @Entity > public class Station { > >@Id >@GeneratedValue(strategy = GenerationType.AUTO) >private long id; > >private String[] names; > >// setter and getter methods > } > > Now what annotation i ve to give to store this array of string names in > single row in Mysql database.. > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/How-to-store-a-string-array-as-a-string-array-using-jpa-tp209875p6561347.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. >
Re: How to store a string array as a string array using jpa?
Thank you so much for ur reply..i go through the document.. First i have to say i'm very new to JPA.., i'm using javax.persistence related packages to annotate my class..means not using org.apache.openjpa.persistence related packages..in that document they gave JPA is not externalized can i mix these two packages in single class.. i constructed my class like this.. @Entity public class Station { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String[] names; // setter and getter methods } Now what annotation i ve to give to store this array of string names in single row in Mysql database.. -- View this message in context: http://openjpa.208410.n2.nabble.com/How-to-store-a-string-array-as-a-string-array-using-jpa-tp209875p6561347.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: How to store a string array as a string array using jpa?
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_extern On Wed, Jul 6, 2011 at 3:37 AM, Suseendran.P wrote: > Hello.., > I'm also looking for the same thing..i check it out the above link but > it's not still alive..so can any one give the proper link or explanation > again.. > Thanks in Advance.. > > -- *Rick Curtis*
Re: How to store a string array as a string array using jpa?
Hello.., I'm also looking for the same thing..i check it out the above link but it's not still alive..so can any one give the proper link or explanation again.. Thanks in Advance.. -- View this message in context: http://openjpa.208410.n2.nabble.com/How-to-store-a-string-array-as-a-string-array-using-jpa-tp209875p6553605.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: How to store a string array as a string array using jpa?
Hi Craig, Thanks very much, yes it's exactly what I was looking for. Thanks again. -- View this message in context: http://www.nabble.com/How-to-store-a-string-array-as-a-string-array-using-jpa--tp15214168p15251389.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: How to store a string array as a string array using jpa?
Hi, If I understand, you want to store a Java String[ ] as a text[ ] in the database. You will need to write a special field externalization method. Take a look at OpenJPA http://openjpa.apache.org/docs/latest/manual/manual.html#ref_guide_pc_extern Using an externalization method allows you to take a String[ ] and convert it to a single String for storage in the text field in the column. Can this be used to solve your issue? Craig On Feb 1, 2008, at 12:20 AM, dave. wrote: Hi Craig, There is text[] data type -among other things- in postgres which can store an array of strings in the same row of table which can do the job of storing an array of strings just perfectly. Actually I think creating another table and all of those keys and etc create extra and unnecessary load on db server specially when the first table is big and there are numerous items in that array. Thanks. -- View this message in context: http://www.nabble.com/How-to-store-a-string-array-as-a-string-array-using-jpa--tp15214168p15222162.html Sent from the OpenJPA Users mailing list archive at Nabble.com. Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp! smime.p7s Description: S/MIME cryptographic signature
Re: How to store a string array as a string array using jpa?
Hi Craig, There is text[] data type -among other things- in postgres which can store an array of strings in the same row of table which can do the job of storing an array of strings just perfectly. Actually I think creating another table and all of those keys and etc create extra and unnecessary load on db server specially when the first table is big and there are numerous items in that array. Thanks. -- View this message in context: http://www.nabble.com/How-to-store-a-string-array-as-a-string-array-using-jpa--tp15214168p15222162.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: How to store a string array as a string array using jpa?
Hi Dave, What would you like the relational schema to be to store the array of String? Not lame. Craig On Jan 31, 2008, at 12:36 PM, dave. wrote: Hi and thanks for trying to help. I'm using jpa and need to store array of strings, but jpa store it as a binary, probably in the serialized form. I can store the given array as a collection but it creates a separate table for this purpose which for me it looks lame, All that I want is to store an array of strings as an array, is there any standard way or propriety way for doing this? Am I missing something in jpa? I'm using openjpa 1.0.1 postgres 8.2 glassfish v2 windows xp Best. -- View this message in context: http://www.nabble.com/How-to-store-a-string-array-as-a-string-array-using-jpa--tp15214168p15214168.html Sent from the OpenJPA Users mailing list archive at Nabble.com. Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp! smime.p7s Description: S/MIME cryptographic signature