-->
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.  [ 2 posts ] 
Author Message
 Post subject: Statically Filtered collections: is there a way to do it?
PostPosted: Wed Dec 31, 2008 9:08 am 
Newbie

Joined: Thu Aug 02, 2007 8:44 am
Posts: 3
Hibernate version:
hibernate 3.2.6.ga
hibernate-annotations 3.3.0.ga
hibernate-commons-annotations 3.3.0.ga


I have a class X with many Y
(a pretty simple one-to-many mapping).

I'll have more complex cases in the real world, but I'd like to tackle that one first.

The class Y has a property z with the possible values: "IMPORTANT", "MAYBE", "IDONTCARE"

I'd like to have (a bit Rails:ActiveRecord-like) methods like:

List<Y> getImportantStuff() {...}
List<Y> getAllStuff() {...}
List<Y> getMaybeStuff {...}

with each of those methods being a mapped collection.

I tried to set up the mapping and a filter using:
Code:
@JoinColumn(name = "id", nullable = false)

but it first complained that it should be mapped with
Code:
insertable = false, updatable = false)

after I set that, I got this error:
Code:
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.test.Machin column: Truc_id (should be mapped with insert="false" update="false")


Is this thing possible?

Futhermore, if I need to rely on @Filter, is it possible to make it always enabled (since my session is injected through Spring)?

Should I forget about setting this through Hibernate mappings and rely on a DAO and HQL directly ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 01, 2009 3:19 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Have you tried the @Where annotation? http://www.hibernate.org/hib_docs/annot ... on-enhance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.