-->
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.  [ 5 posts ] 
Author Message
 Post subject: Choosing a Connection dependend on the SQL-command ?
PostPosted: Fri Jan 09, 2004 2:50 pm 
Newbie

Joined: Sat Sep 20, 2003 1:09 pm
Posts: 8
Hello,

MySQL has a possibility to run in a master/slave replication configuration.
That means that there are 2 machine running a database-server-program.
One is the master and one the slave.
The master should take care of all UPDATE/DELETE/INSERT statements.
The slave CAN be used to execute SELECT statements.
So reads can be divided between master and slave which could be a huge
performance win.

Is it possible in Hibernate to configure this ?

Kees.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2004 3:08 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 1:24 pm
Posts: 213
Location: Richardson, TX
Not sure, but you could try C-JDBC (Clustered JDBC)

http://c-jdbc.objectweb.org/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2004 3:22 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 1:24 pm
Posts: 213
Location: Richardson, TX
Oh yeah, also two different configurations.

For the write side, a normal configuration with a straight MySQL JDBC setup, pointing to the master DB.

For the read side, a C-JDBC setup with a slightly altered mapping file. (Set mutable="false" for all class mappings, for starters.)

Now, you wouldn't use both of these setups simultaneously. (though, I suppose you could, if you were careful.) This setup is best if you've got some read/write clients and some read-only clients.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 10:58 am 
Newbie

Joined: Fri Feb 06, 2004 6:23 pm
Posts: 1
Location: Calgary
We had to do something similiar to this but in our case we had two distinct systems. One system was permitted to read, insert, update and delete various domain objects and the other system was only permitted to read those domain objects. Each system had it own set of domain objects. Specifically, we have one system that uses TOPLink and the other uses Hibernate using the same database in the same VM. Lots of fun!

In the read only system, we extended the net.sf.hibernate.persister.EntityPersister with our own class called ReadOnlyPersister that overrided the various insert, delete and update methods. Each domain object that was to be read only, would specify the ReadOnlyPersister and set mutable to false.

In each overridden method in the ReadOnlyPersister, a HibernateException is thrown with a "Not allowed to update, etc" message. We wanted the read only system to fail hard if an attempt was made to insert, update or delete any data.

In the mappings, we specified the persister and set mutable to false. We had to modify XDOCLET to generate the hibernate mapping files with the persister element in them.

It should be noted that not all Session.update() calls seem to make it to the various EntityPersister.update() methods on domain objects with mutable set to false. Some do and some don't. I'm currently stepping through hibernate code to increase my understanding.

Hope this helped!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 12:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
It should be noted that not all Session.update() calls seem to make it to the various EntityPersister.update() methods on domain objects with mutable set to false. Some do and some don't.


Interesting. There is probably some good reason for this but I don't quite recall. Actually, ALL should result in a lock(), rather than an update().


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