Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF - Teneo - Hibernate - Collection - Object(how to store a collection that stores Object)
EMF - Teneo - Hibernate - Collection - Object [message #731911] Mon, 03 October 2011 13:13 Go to next message
Herve Ferreira is currently offline Herve FerreiraFriend
Messages: 31
Registered: October 2011
Member
Hi have one Class that contains a property that's a collection of objects. All the objects are JPA entities, however, there are no relations between them.

So, can I in some what store a class that contains a list of object?

Thanks
Re: EMF - Teneo - Hibernate - Collection - Object [message #731916 is a reply to message #731911] Mon, 03 October 2011 13:19 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Herve,
I don't fully understand the question, but afaics the answer is yes you can store an object which has a list of objects.

gr. Martin

On 10/03/2011 03:13 PM, Herve Ferreira wrote:
> Hi have one Class that contains a property that's a collection of objects. All the objects are JPA entities, however,
> there are no relations between them.
>
> So, can I in some what store a class that contains a list of object?
>
> Thanks


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: EMF - Teneo - Hibernate - Collection - Object [message #731987 is a reply to message #731916] Mon, 03 October 2011 15:44 Go to previous messageGo to next message
Herve Ferreira is currently offline Herve FerreiraFriend
Messages: 31
Registered: October 2011
Member
Hi Martin

The entity that I want to store is something like this:

class Network
{
    private String networkName = "someName";
    private List<Router> routers
    private List<EObject> myItems;//Problem relies here :(, how to store myItems

... Constuctors/Getters/Setters/....
}


and that I save/load the same object for both routers and myItems.

Router router = factory.createRouter();
Network net = factory.createNetwork();

net.getRouter().add(router);
net.getMyItem().add(router);

session.save(net);




I already tried to replace the EObject by EJavaObject (which is not clear the difference for me) but what I checked in the tests is that for EJavaObject the objects are basically serialized to a varchar field. When deserialized from the database different objects are created (for routers and myItems).

This means that-> net.getRouter().get(0) != net.getMyItem().get(0);

How can I store this then?

Thanks in Advance

[Updated on: Mon, 03 October 2011 15:46]

Report message to a moderator

Re: EMF - Teneo - Hibernate - Collection - Object [message #732045 is a reply to message #731987] Mon, 03 October 2011 18:26 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Herve,
Not sure why this is a problem, this is like a standard case for Teneo to handle, or is the Network class not an EMF
object?
In that case (and if you are not doing an RCP), I advice to check out the Texo project which gives you better pojo
integration and standard JPA behavior.
http://wiki.eclipse.org/Texo

gr. Martin

On 10/03/2011 05:44 PM, Herve Ferreira wrote:
> Hi Martin
>
> The entity that I want to store is something like this:
>
>
> class Network
> {
> private String networkName = "someName";
> private List<Router> routers
> private List<EObject> myItems;//Problem relies here :(, how to store myItems
>
> ... Constuctors/Getters/Setters/....
> }
>
>
> and that I save/load the same object for both routers and myItems.
>
>
> Router router = factory.createRouter();
> Network net = factory.createNetwork();
>
> net.getRouter().add(router);
> net.getMyItem().add(router);
>
> session.save(net);
>
>
>
>
> I already tried to replace the EObject by EJavaObject (which is not clear the difference for me) but what I checked in
> the tests is that for EJavaObject the objects are basically serialized to a varchar field. When deserialized from the
> database different objects are created.
>
> This means that-> net.getRouter().get(0) != net.getMyItem().get(0);
>
> How can I store this then?
>
> Thanks in Advance
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: EMF - Teneo - Hibernate - Collection - Object [message #736759 is a reply to message #732045] Fri, 14 October 2011 09:58 Go to previous message
Herve Ferreira is currently offline Herve FerreiraFriend
Messages: 31
Registered: October 2011
Member
If I have

 EList<EObject> myContainer = ...


I have to change the objects to implement a common interface and also change the container to use the interface in the generic

 EList<IGenContainer> myContainer = ...


At least was this the solutions that I found
Previous Topic:How to load an XML fragment?
Next Topic:[EMF Compare] Visibility in StatisticBasedSimilarityChecker
Goto Forum:
  


Current Time: Sat May 11 23:46:52 GMT 2024

Powered by FUDForum. Page generated in 0.03716 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top