-->
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.  [ 7 posts ] 
Author Message
 Post subject: List<String> with CollectionOfElements & EAGER
PostPosted: Mon Oct 15, 2007 3:24 am 
Newbie

Joined: Wed Jul 04, 2007 6:29 am
Posts: 11
Hi All,

I am trying to persiste an Entity (JPA with Hibernate) with a List<String>.
I can't use the OneToMany association because String is not an Entity.
So I use the @CollectionOfElements annotation, but it's not seen as a OneToMany assocation :
When I fetch the element, I have N instance of DataSet, where N is the number of element of listOfString

The entity:
Code:
@Entity
public class DataSet {
...
   @CollectionOfElements(fetch=FetchType.EAGER)
   @IndexColumn(name="listOfString")
   [b]private List<String> listOfString[/b];
..
}

The fetching code:
Code:
em.createQuery("SELECT d FROM DataSet d");


I read this post, saying that "HQL queries are not affected by the fetching strategy at all."
http://forum.hibernate.org/viewtopic.php?t=971700&highlight=onetomany+collectionofelements
But it's not my case, with EAGER, my list is loaded, but I have N instance of DataSet, where N is the number of element of listOfString

Can anyone help me please ?

Regards,
Samuel


Last edited by samuel.michelot on Mon Oct 15, 2007 5:23 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 4:10 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
I do not understand how the query is related to your mapping.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 5:24 am 
Newbie

Joined: Wed Jul 04, 2007 6:29 am
Posts: 11
LaLiLuna wrote:
I do not understand how the query is related to your mapping.


Sorry, it's fixed now (I simplified my code for better comprehension)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 12:55 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
If would be nice to share your solution.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 16, 2007 3:17 am 
Newbie

Joined: Wed Jul 04, 2007 6:29 am
Posts: 11
I am still looking for a solution, I corrected my previous post, but I don't have the solution of my problem....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 4:43 am 
Newbie

Joined: Wed Jul 04, 2007 6:29 am
Posts: 11
I need help please. I am still stuck with this problem. I tried a lot of configuration, but it's still not working :-(


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 5:05 am 
Newbie

Joined: Wed Jul 04, 2007 6:29 am
Posts: 11
I found a solution. I added @Fetch(FetchMode.SUBSELECT) to fetch the list with another sql request :

@CollectionOfElements(fetch = FetchType.EAGER)
@IndexColumn(name = "listString")
@Fetch(FetchMode.SUBSELECT)
private List<String> listString;


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.