-->
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.  [ 3 posts ] 
Author Message
 Post subject: Help! How to implement a User Defined Collection Type?
PostPosted: Fri Jan 20, 2006 9:01 pm 
Newbie

Joined: Fri Jan 20, 2006 12:39 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1

Name and version of the database you are using: MS-SQL Server 2000 OR HSQLDB


I am just wondering...

If it is possible to define a user defined collection Class, and have it interact with Hibernet. In additionally, works exactly same as the Set, List, or Map?

For example:
With the Annotation of @ManyToMany, between Table A and B; Hibernate will create a new Table call A_B with all the required columns.

Therefore, is that possible for me to create a classType called "ListenerSet" which work exactly the same as the Java Set class and create the same Tables. In addtional, with the listener trigger in the class?

(Note that "ListenerSet" can be implement from Set)



Currently, I implement everything as Set. However, when someone modify the DataTable; I would like to notify all the users that DB has been changed and do whatever next.




Thank you for your time....
Jeremy


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 21, 2006 4:35 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
I'm not sure what hooks hibernate has for inserting callbacks (listeners) - howevre, if you are using JBoss you can make use of the pre-event or post-event listeners or if you are using a Spring framework you could make use of AOP to drop a listerner in that way, and thus you can continue using java.util.Set.
Alternatively, why not just make the notification from the update method of the DAO if you are happy to embed it in code?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 21, 2006 4:39 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Ok, had a quick search and hibernate does indeed allow listeners to be registered.
Have a read of http://www.hibernate.org/hib_docs/v3/re ... vents.html

I suspect you want a pre-update (or post is better if they have one) listener that checks to see if you parameters of interest are being changed, and then make the notification to your users.

This is a much cleaner way of doing it, than creating custom Collection types.


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