Hey Folks, I have a relation mapped as follows:
@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY) private Map<String, FPropertyValue> properties;
I'm trying to access an attribute of the FPropertyValue in that properties map with key 'receivingDate'.
I've tried something like the following:
select distinct actentry from FActivityEntry actentry join actentry.properties property where index(property)='receivingDate'
I get this error: "index() function not supported for many-to-many association"
I also tried something like: select distinct actentry from FActivityEntry actentry where actentry.properties['receivingDate'].timestampValue.serverTimeSaved < :endDate
(Overall my goal is to filter the results based on that date property.)
Doing that, I got bad sql that wouldn't execute, along the lines of the following:
select distinct fpropertyv5_.timestampvalue_servertimesaved, factivitye0_.id as id12_, factivitye0_.currentsystem_id as currents4_12_, factivitye0_.sourcesystem_id as sourcesy5_12_, factivitye0_.ACTIVITY_RUN_ID as ACTIVITY6_12_, factivitye0_.status as status12_, factivitye0_.SUBJECT_ID as SUBJECT7_12_, factivitye0_.tag as tag12_, factivitye0_1_.corelab_id as corelab3_13_, factivitye0_1_.tubestatus as tubestatus13_, case when factivitye0_1_.ID is not null then 1 when factivitye0_.id is not null then 0 end as clazz_ from FActivityEntry factivitye0_ left outer join FUpdateTubesActivityEntry factivitye0_1_ on factivitye0_.id=factivitye0_1_.ID, FTube ftube1_ inner join FItem ftube1_1_ on ftube1_.ID=ftube1_1_.id inner join FMetaObject fstudy2_ on ftube1_.STUDY_ID=fstudy2_.id, FActivityRun factivityr3_, FActivityEntry_FPropertyValue properties4_, FPropertyValue fpropertyv5_ where factivitye0_.ACTIVITY_RUN_ID=factivityr3_.id and factivitye0_.id=properties4_.FActivityEntry_id and properties4_.properties_mapkey = 'receivingDate' and properties4_.properties_id=fpropertyv5_.id and (fstudy2_.displayname like '%') and factivitye0_.SUBJECT_ID=ftube1_.ID and cast(factivityr3_.ACTIVITY_TYPE_ID as varchar(255))='c19af432-2a97-419d-8085-578522d9aa4b' and properties4_.timestampvalue_servertimesaved>'2009-12-08 23:00:00-07'
Note that the sql generated looks for the timestamp column on the join table, rather than on the FPropertyValue table where it should.
Anyone have any idea of how I might go about making either of the above methods work or otherwise traversing that relationship and filtering based on the date in that property?
I am using the following versions: hibernate core: 3.2.5.ga hibernate-annotations: 3.4.0.GA hibernate-entitymanager: 3.3.2.GA
|