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 ?