-->
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.  [ 6 posts ] 
Author Message
 Post subject: decentral registration of xml-mappings in jboss
PostPosted: Thu Feb 12, 2004 6:07 am 
Newbie

Joined: Thu Feb 12, 2004 5:42 am
Posts: 4
Location: Germany, Freiburg i.Br.
Hello!

I'm using jboss 3.2.2 with hibernate 2.1. All the documentation I found told me, the use of hibernate within jboss works like this:

I register the hibernate service by creating a directory (e.g. "hibernate.sar") in the deploy-directory of my jboss server and put some config files into it. Well, this was no problem and I got a little test project working.

But, what I don't like at the current scenario is that it seems to me, I've to register all mapping-xml-files in {jboss}/server/default/deploy/hibernate.sar/META-INF/jboss-service.xml. Is there a way to decentralize the registration of mappings? I mean to configure the hibernate service in a way, it automatically registers all hbm.xml-files that are deployed?

Because in the documentation of Configuration it's written that a SessionFactory is immutable, I think there is no way to register mappings after I looked up the SessionFactory from JNDI?!

I hope that you understand what I mean. A central xml-config with thousands of _manually_ registered mapping files looks quite ugly to me and I can't believe that this is the preferred way to use hibernate in jboss.

Thousand thanks for a quick reply!

Best regards, Marco ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
There is a new (so far very experimental) Hibernate deployer in JBoss CVS (in the hibernate module). We appreciate anyone who wants to try out and help improve this.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2004 4:13 am 
Newbie

Joined: Wed Feb 18, 2004 4:07 am
Posts: 3
Location: Emeryville, CA
I've decided to take the plunge and experiment with you! I'm using JBoss 3.2.3 and Hibernate 2.1.2. (Oh, and first post here!)

My first problem is in the getProperties() method of the Hibernate deployer. The hibernate-service.xml needs an exhaustive set of properties. If you don't define all properties, there's a NPE in java.util.Properties.setProperty(). I would move the setProperty() call into a safe helper method that would not call it if the value is null. I'm sure that later on in Hibernate configuration, reasonable defaults exist.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2004 5:14 am 
Newbie

Joined: Wed Feb 18, 2004 4:07 am
Posts: 3
Location: Emeryville, CA
The SessionFactory created when a har is deployed is not exposed via JNDI, which is necessary to use it.

I was wondering, though... I'm interested in being able to add and remove mappings to/from an existing SessionFactory, or at least have an MBean that rebuilds the SessionFactory when a new mapping comes along. I'd like to end up with one SessionFactory per database, not one per set of mappings. Of course, I could see this getting a bit fragile when classloaders are thrown into the mix.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2004 12:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
The SessionFactory binds itself to JNDI, as long as you specify the JNDI name in your Hibernate properties.

You should be able to dynamically replace the har archive and the deployer will rebuild the SessionFactory and all needed classloaders will be cycled.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2004 1:39 pm 
Newbie

Joined: Wed Feb 18, 2004 4:07 am
Posts: 3
Location: Emeryville, CA
I should have looked before questioning the JNDI thing.

Still, I like the modularity but I want to have as few session factories as possible. I have one part of my application that needs mappings A and another part that needs mappings A and B. I think I might make a central Hibernate MBean, and satellite mapping MBeans. When the mapping MBean is registered, it sends a message to the Hibernate MBean saying to load its mapping files as well. The Hibernate MBean then adds those mappings to its configuration and rebuilds the session factory. Similar when the mapping MBean is deregistered.


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