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: Multi-client capable applications
PostPosted: Fri Jun 17, 2005 5:58 am 
Newbie

Joined: Fri Jun 17, 2005 2:51 am
Posts: 11
Hi,

I'm using Hibernate 3.0.x and we have a multi-client capabel DB design, which means that every table in the DB has an additional field "client" that contains the id of the client this record belongs to. Note that there exists an ID column as primary key that is unique over all table entries, i.e. the client is not part of the primary key.

Now I have two challanges with this multi-client awareness: First, I have to filter the data on every data retrieval process and, secondly, I have to write the "client" on every newly created record.

Additional architecture information: The client information is stored in a ThreadLocal variable, i.e. it can be accessed at any time.
The Hibernate Persistence layer lies behind a Data Access Object layer, i.e. all data retrieval is done via DAO methods.
For data retrieval I can think of the following solutions, where the first solution (filter) seems to by my favorite:
  1. I use a Filter that I set at the session creation time.
  2. I add the filtering manually to every DAO finder/retrieval method.
  3. I try to use the interceptor or event system in any way (if possible at all).
For data storage I can think of the following three solutions:
  1. I use an interceptor for writing the client information in the onSave() method.
  2. I implement the SaveOrUpdateEventListener of the Hibernate event system for writing the client information.
  3. As all data objects are created via the DAOs I set the client information within the DAO.


My favorite solution is the Filter for retrieving data and the interceptor or SaveOrUpdateEventListener for writing data.

If you have any experience with multi-client applications or if you can think of any other solution or if you have any other comments on this I would be very interested in reading your forum post...

Best regards,
Joern


Top
 Profile  
 
 Post subject: Hi
PostPosted: Tue Dec 18, 2007 10:53 am 
Beginner
Beginner

Joined: Sun Feb 19, 2006 5:13 am
Posts: 22
I don't get it in the DefaultSaveOrUpdateEventListener I want to set the cretionDate and/or updateDate.

Whats the difference between the getObject and getEntity ?

It does not work when I do nothong get persistent in the database


public class CRUDSUpdateEventListener extends DefaultSaveOrUpdateEventListener {
public void onSaveOrUpdate(SaveOrUpdateEvent event) throws org.hibernate.HibernateException {
if (event.getObject() instanceof Editable) {
Date date = new Date(System.currentTimeMillis());
Editable editable = (Editable)event.getObject();
editable.setCreationDate(date);
editable.setUpdateDate(date);
}
super.onSaveOrUpdate(event);
}
}



Any one ?

Cheers
Magnus


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.