-->
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: onPostUpdate, content set<string> in oldState BUG?
PostPosted: Fri Feb 06, 2009 2:11 pm 
Beginner
Beginner

Joined: Fri Sep 26, 2008 2:39 am
Posts: 20
Hi everyone,

my problem is about a "collection-of-value" in an onPostUpdate Eventlistener:

onPostUpdate in the PostUpdateEvent I check getOldState against getState and all properties differ correctly except the set of strings.

It's the same Set in oldState and in state (always the new set):

The Object has a set of strings like this:

set<String> tags;

It's mapped like this:

<set name="tags" table="search_demo_person_tags" lazy="true">
<key column="object_id"/>
<element column="tag" type="string"/>
</set>


The object is saved by:

session.merge(object);


I load the object, set a new set of strings and i call merge.
In the postUpdateEvent in both oldState and state the same (the new) set of strings is presented.
I tried setting lazy="false" but that doesn't change anything (why would it).


Is there a way to fix this?


Why do I want/need this?

My plan is to keep track of how many objects have a given string in their set. - If the oldState and State would differ correctly i could decrease/increase the count for the missing/added string.
The set of strings represents a set of tags given to a business object by the users.

I can't use a set of Tags (and implement a Tag class) because that would mean all Tags end up in the same db-table and the businessobjects only have a table with foreign keys to that global tag table.

(With the strings each businessobject type has its own table, that's required.)

The only half solution i found on my own is to use an array of strings. (there the difference is correct between oldState and state) - But it has a very very big downside - it can't be loaded lazy... so every business-object needs two selects to be loaded even if the tags are unimportant for the performed operation, that is not really acceptable.

Well thanks for reading, and i hope somebody will be able to provide a tip.

ps: just noticed that this is maybe more of a hibernate than a hibernate-search problem.. i don't want to double post, so if somebody could move this, that would be great.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 07, 2009 10:58 am 
Beginner
Beginner

Joined: Fri Sep 26, 2008 2:39 am
Posts: 20
I have now also tested it with a composite set:

<set name="tags" table="serach_demo_person_tags" lazy="true">
<key column="taggedObjectID"/>
<composite-element class="org.osbl.persistence.model.search.Tag">
<property name="date"/>
<property name="text"/>
<property name="kicksAndGiggles"/>
</composite-element>
</set>

The effect remains the same, oldState and state differ correctly in everything but the set. The set is still the new set in both states.


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.