-->
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.  [ 7 posts ] 
Author Message
 Post subject: Generate HBM files from Java files for JBoss
PostPosted: Mon Jul 31, 2006 5:18 am 
Newbie

Joined: Thu Jul 27, 2006 3:13 am
Posts: 3
Hi,

Does anyone know whether it is possible to generate HBM files from Java files rather thatn the Eclipse Hibernate plugin creating the HBM files from the database? We need to use the MBean in JBoss, and in order to use the MBean the HBM mapping files are needed.

Of course we have the hibernate.cfg.xml with all the pojos, but we can't use this to configure JBoss, at least as far as I can see in the documentation.

Thanks in advance

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 7:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
who told you that our plugin is only for reverse enginering ?

the plugin (ant and eclipse) can do its code generation from jdbc, hbm.xml's & annotations.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: HBM generation.
PostPosted: Tue Aug 01, 2006 2:54 am 
Newbie

Joined: Thu Jul 27, 2006 3:13 am
Posts: 3
Thanks Max,

I saw the annotations and how they can be used for the HBM generation. Which is a solution of course, but an enormous ammount of work for us now.

We made the error of using the hibernate.cfg.xml, and then just the 'standalone' config for Hibernate, which means that the server will not manage the Hibernate session, i.e. the hibernate transaction in the server transaction or close the session. Now we are in trouble because nothing is in the server transaction.

Of course we have to change to the MBean for this transaction functionality which is a huge pain now.

Anyhow thanks for the response.

Regards

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 4:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
huh ? I do not understand any of your points since they all seem to be false.

What is it you actually want to do ?

Using hibernate.cfg.xml is not wrong
It is not a requirement to use MBean to get the session managed etc. etc.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 11:24 am 
Newbie

Joined: Thu Feb 16, 2006 2:18 pm
Posts: 4
Location: Colorado
You could try to put in the Xdoclet tags in your POJO's. IE:

@hibernate.class table="someTable"

@hibernate.property column="columnName"
public String getColumnName() {
return columnName;
}

I am a bit new to Hibernate, and not convinced that Xdoclet is the way to go, but at this point I think it is simpler than writing the HBM files. However, I think that you are going to ultimately get more control through using the Toolset however mastering the toolset is an artform in and of itself. If you are not needing complex control, this will get you started quickly, and is simple to implement.

Here is the XDoclet reference:

http://xdoclet.sourceforge.net/xdoclet/ ... -tags.html

In your buildfile, you will want to have something along the lines of

<target name="generate-hbm" description="Generate Hibernate hbm.xml file">
<taskdef name="hibernatedoclet"
classname="xdoclet.modules.hibernate.HibernateDocletTask"
classpathref="xdoclet.lib.path" />

<mkdir dir="${build.dir}" />
<mkdir dir="${gen.source.dir}" />

<hibernatedoclet destdir="${gen.source.dir}">
<fileset dir="${source.dir}">
<include name="**/*DTO.java" />
<include name="**/*DO.java" />
</fileset>

<hibernate version="3.0" />

</hibernatedoclet>
</target>

Good Luck.


Top
 Profile  
 
 Post subject: Change to MBean in Hibernate and JBoss
PostPosted: Fri Aug 04, 2006 2:17 am 
Newbie

Joined: Thu Jul 27, 2006 3:13 am
Posts: 3
Hi Max and Fredpope,

Thanks Fredpope, that is exactly what we will need to do in fact. Putting in all the Hibernate annotations is exactly what I was trying to avoid due to the workload at this point, but there seems no other way.

Max we are using the basic setup of Hibernate in JBoss, i.e. the hibernate.cfg.xml to configure Hibernate. The trouble is with this setup that JBoss will not close the Hibernate session. Consequently after +- 12 hours the database closes the connection automatically and we get an exception. The solution is to use the MBean from JBoss. In this way the server will close the Hibernate session. However to use the MBean it has to be configured using the HBM files for each Pojo that you need to configure. But the workload to put in all the Hibernate annotations is great.

Eventually we will use the MBean and in fact put in all the annotations. Another problem that I've discovered is the two stage commit from the database, MySql 4.1 which it does not support two stage commit from the server. The upshot of all this is that we do an insert, then send a JMS to update the clients. All goes but the JMS is faster than the database commit so we get some exceptions from the clients because they go to the database to update the GUI before the data is ready.

So finally the colution is to use the MBean and update the database to the 5.5 version.

In any event thanks for the responses.

Regards

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 3:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
2 things:

annotations != xdoclet

auto-closing session does not require MBean. Read up about getCurrentSession() and how you can get autoclose when running with container managed tx's.

_________________
Max
Don't forget to rate


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