You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by "Suseendran.P" <su...@yahoo.com> on 2011/07/06 10:37:51 UTC

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?

Posted by Michael Dick <mi...@gmail.com>.
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 <ha...@uni.no>

> Hi
>
> I use something like this
>
> @PersistentCollection
>    private List<String> subEntries = new LinkedList<String>();
>
> 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 <su...@yahoo.com> 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?

Posted by Håkon Sagehaug <ha...@uni.no>.
Hi

I use something like this

@PersistentCollection
    private List<String> subEntries = new LinkedList<String>();

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 <su...@yahoo.com> 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?

Posted by "Suseendran.P" <su...@yahoo.com>.
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?

Posted by Rick Curtis <cu...@gmail.com>.
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 <su...@yahoo.com> 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*