-->
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.  [ 9 posts ] 
Author Message
 Post subject: My Hibernate Tools issues
PostPosted: Sun May 22, 2005 6:18 am 
Newbie

Joined: Sun May 22, 2005 6:09 am
Posts: 10
Hey,

I've been using the hibernate tools plugins for Eclipse. I've noticed some things which annoy me.

I'm using hibernate 3.0, Eclipse 3.1M7 and the latest tools available on the website. My database is postgresql 8.0.

One thing I notice is that when you do SchemaExport, it doesn't seem to be issuing enough commits. I've seen the state whereby I do something on the connection which fails, then my subsequent queries will continue to fail until I reconnect. This is because postgresql won't properly process queries on a transaction with errors. By sending more commits that would clear that problem up nicely.

Also, it would be nice for Schema Export to allow me to export to a .sql file. That way I can generate the SQL once and execute it as many times as I want, also it would allow me to source control the DDL. As well as issuing partial creates, such as in the case of adding new fields.

The most perplexing thing though is Java code generation. The code generator doesn't generate a full constructor with all public non-ID fields. It also doesn't create equals(), toString() and hashCode(). It's not a huge deal, but it means I have to use Eclipse's constructor generator, which is cool, but it messes up the roundtrip generation.

But the most annoying thing is for some reason my types are being mapped from the .hbm.xml file to the .java file. That is, if I label a column as having Java type 'int' it will get the type 'Integer'. Or if I say it is a java.sql.Time, I will end up with a java.util.Date. This I cannot figure out.

I really like what I see so far, but these issues I find are a minor thorn in my side. Do I need to be using the CVS version?

Thanks,
-ryan


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 22, 2005 11:56 am 
Hibernate Team
Hibernate Team

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

First thank you for your feedback....here are my comments:

FYI - using 3.1M7 with the plugin is not guaranteed to work unfortunately.

Your issue with schemaexport not issuing commits while operation I don't follow precisely, but it sounds like something that should be explained with a testcase and added to our JIRA.

SchemaExport does allow export to a file - just use the ant task for it.

If you want the gui to generate it instead then please submit a feature request for it.

Full constructors and toString() are not added yet, just need feature request for it....see http://hibernate.org/276.html

equals() and hashcode() is not implemented by default because its not SAFE, see http://hibernate.org/109.html.
You can though mark properties as something to be included in equals and hashcode, see docs for meta attributes.

The mapping of type is because at the version you are using we are just listening to what the underlying Hibernate type returns...and since 'int' is the short Hibernate type name then it gets to be java.lang.Integer.

In cvs version you have more control over this.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 22, 2005 3:40 pm 
Newbie

Joined: Sun May 22, 2005 6:09 am
Posts: 10
Hey,

Thanks for the reply. I'm kind of a Eclipse/Ant newbie, so bear with me. I'm not really clear on how to get the ant task to generate output files for me... I'm relying on Eclipse heavily here... I'm under the impression that I can create custom/manual ant targets in Eclipse, so therefore I could get auto-generation of DDL from my hbm.xml files as I change them. Maybe :-)

As for the short-name of the types in the mapping file... I'm still new on this. Do you have any good pointers for me?

One last question, the hbm2java seems to create a base template to go from - that is it requires some customization after the fact (constructors and hashcode/equals). What is the concept here? Is the intent that the hbm2java just be a starting point, versus a full roundtrip engineering solution? Or was the hope to have these classes to be 100% complete without needing modification?

Thanks for the help.

-ryan


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 22, 2005 3:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Here is the cvs docs for the latest ant stuff http://cvs.sourceforge.net/viewcvs.py/* ... ml?rev=1.7

The pojo's are intended to be more or less usable out of the box when you have the relevant info in the .hbm.xml files. (but users has different needs so it wont work everytime...but it surely is the goal to have a good roundtrip solution - and i actually think we have all the mechanisms for it implemented)

Look up the meta attribute documentation.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 22, 2005 11:35 pm 
Newbie

Joined: Sun May 22, 2005 6:09 am
Posts: 10
The CVS version sounds like fun. Is there a way to get a snapshot without building it from cvs? It would seem to build the eclipse extensions I would have to mess about with a pile of installations and other things...


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 2:00 am 
Newbie

Joined: Sun May 22, 2005 6:09 am
Posts: 10
Hey,

I found out where the alpha2 download is - the JBoss IDE download page. Kind of counter intuitive. Until I saw that I was under the impression the last update was Jan 24th.

I've been working through the book "Hibernate: A Developers Notebook". The book uses H2 with the tools suite. He noted that the old hbm2java would generate join-table classes. That is the table defined in a <composite-element> tag inside a <list> tag/property. The new Eclipse driven hbm2java doesn't seem to do that. Is this something that is known?

Thanks for all the great help!
-ryan


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 2:37 am 
Hibernate Team
Hibernate Team

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

I don't complete get what you are saying....?

Do you mean hbm2java generates classes for Component's then yes, that is something it will/should do.

If it's not then its a bug.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 3:13 am 
Newbie

Joined: Sun May 22, 2005 6:09 am
Posts: 10
Yes, generation of components doesnt seem to be working right now.

eg:, this hbm.xml snippet:
<list name="tracks" table="ALBUM_TRACKS" cascade="all">
<meta attribute="use-in-tostring">true</meta>
<key column="ALBUM_ID"/>
<index column="POSITION"/>
<composite-element class="com.ryan.AlbumTrack">
<many-to-one name="track" class="com.ryan.Track" cascade="all">
<meta attribute="use-in-tostring">true</meta>
<column name="TRACK_ID" />
</many-to-one>
<property name="disc" type="integer" />
<property name="positionOnDisc" type="integer" />
</composite-element>
</list>

In this example (from the book mentioned above), the composite class com.ryan.AlbumTrack should hopefully be autogenerated. But it is not. Is this a bug?

Thanks!
-ryan


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 3:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
most likely yes.

_________________
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.  [ 9 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.