-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: How to get java.util.List instead of PersistentList?
PostPosted: Mon Mar 08, 2010 11:19 am 
Newbie

Joined: Sat Oct 25, 2008 2:09 pm
Posts: 6
Hi all,

I have a java.util.List Object 'addresses' in a 'Person' entity like this:

[code]
@OneToMany(cascade = { CascadeType.ALL })
@IndexColumn(name = "idxAddresses")
@JoinTable(name = "person_addresses", joinColumns = { @JoinColumn(name = "person_id", referencedColumnName = "id") }, inverseJoinColumns = @JoinColumn(name = "address_id", referencedColumnName = "id"))
private List<Addresses> links;
[/code]

When I load an entitiy from the database, the 'address' column is of a type 'PersistentList' instead of 'java.util.List'. However I would like to retrieve a 'java'util.List' object.

Is this possible and what do I need to do, to retrieve the 'address' Object as a List object?

Thanks in advance!!!
Paul


Top
 Profile  
 
 Post subject: Re: How to get java.util.List instead of PersistentList?
PostPosted: Mon Mar 08, 2010 11:57 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Paul,

java.util.List is just a Interface !
The type of any concrete java instance cannot be of type interface.
BTW: org.hibernate.collection.PersistentList implements java.util.List
so you can assign it to a variable of type java.util.List.

Code:
java.util.List mylist = myPersistentObject.getAddresses();


Top
 Profile  
 
 Post subject: Re: How to get java.util.List instead of PersistentList?
PostPosted: Mon Mar 08, 2010 4:14 pm 
Newbie

Joined: Sat Oct 25, 2008 2:09 pm
Posts: 6
Thanks for the answer!

Yes, in Java I can simply access the list by using the getter, however I run Adobe Flex (Framework to generate Flash) on the client and I think Flex serialization can not handle the PersistentList object...
Here is my problem. Is there any way to tell Hibernate not to use the PersistentList?

Thanks!
Paul


Top
 Profile  
 
 Post subject: Re: How to get java.util.List instead of PersistentList?
PostPosted: Wed Mar 10, 2010 3:50 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
Is there any way to tell Hibernate not to use the PersistentList?


I fear not.

On the other hand I just saw that PersistentList extends AbstractPersistentCollection which implements Serializable,
so Flex in theory should be able to de/serialize PersistentList. Doesn't it ?


Top
 Profile  
 
 Post subject: Re: How to get java.util.List instead of PersistentList?
PostPosted: Sat Mar 13, 2010 9:05 am 
Newbie

Joined: Sat Oct 25, 2008 2:09 pm
Posts: 6
Yes should be, but I think I need to learn more about serialization and complex objects in Flex.... still working on.
Thanks for all the help!!

Paul


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.