-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Tools missing features?
PostPosted: Mon Aug 22, 2005 5:58 pm 
Newbie

Joined: Tue Aug 16, 2005 1:27 pm
Posts: 7
I've recently ported my application from hibernate2 and middlegen to hibernate3 and hibernate tools. I've read all the documentation, and finally gotten my application to compile and run successfully. However, there are a few things I haven't been able to figure out.


(1) When I run hibernate tools, I use a direct JDBC connection to the database, which I specify in a hibernate.properties file. However, the application uses a JNDI connection (specified in hibernate.cfg.xml). If I use the <hbm2cfgXml> target, it will write an hibernate.cfg.xml file which has the JDBC bindings. However, I want the mappings to be updated, so that when a new database table is added, it is properly reflected. How can I do this? (Right now, I'm handling this with a python post-processing script, but that is not ideal).

(2) I'd like to add some more java code tothe POJO's created by <hbm2java>. There is mention of a templates dir in the hibernate tools documentation, but no examples on how it works, and no templates. How do I do this? In particular, I'd like to add serialVersionID to every POJO (to stop getting warnings), and I'd like to add a multiple-arg constructor that takes every column (except the sequence primary key if present).

(3) Speaking of sequences, hibernate tools fails to recognize sequences (in postgresql). I had to modify the .hbm.xml files by hand to insert <generator class="sequence"> and add the <param name="sequence">database_sequence_id</param>.

(4) How do I add <cache usage="transactional"/> to all .hbm.xml files? I've had to do this by hand as well.

(5) When I run with a log4j.xml set to ERROR, I see this error repeated over and over
    [hibernatetool] 14:57:01,754 ERROR [template] Left side ($property.cascade) of '!=' operation has null value. Operation not possible. hbm/many-to-one.hbm.vm [line 13, column 26]
    [hibernatetool] 14:57:01,757 ERROR [template] RHS of #set statement is null. Context will not be modified. hbm/many-to-one.hbm.vm [line 16, column 1]
    [hibernatetool] 14:57:01,757 ERROR [template] Left side ($fetchmode) of '!=' operation has null value. Operation not possible. hbm/many-to-one.hbm.vm [line 17, column 19]
    [hibernatetool] 14:57:01,789 ERROR [template] Left side ($property.cascade) of '!=' operation has null value. Operation not possible. hbm/many-to-one.hbm.vm [line 13, column 26]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 3:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
#1 the <hbm2cfgxml> takes whatever you have configured the <configuration> with. If you need to have some different setup when doing reveng (to use local jdbc) then you just do different runs of the
tools - one with the two different setups.

#2 http://www.hibernate.org/hib_docs/tools ... .html#gen9
And also be aware that we have <meta attribute="class-code"> that you can use to add arbitrary extra code with.

Any enhancements yo make (like serialversion etc.) is very welcome in our Jira ,)

#3 Yes - revengineering doesnt try to autodetect id generation, dont know if it can do it reliably. Add a feature request for it, but it will probably just be something you can specify per table in reveng.xml

#4 Best way currently is do copy the relevant template from the jars and add these tags your self.

#5 yes, velocity is so kind to tell me it doesnt know how to compare a null value ;) Put them in jira and i'll see if we can add some guards to the logs doesnt get so pollutted

p.s. please add separate jira issues (not one big one)

/thanks

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 12:43 pm 
Newbie

Joined: Tue Aug 16, 2005 1:27 pm
Posts: 7
#2: How do I specify <meta attribute="class-code"> xml during reverse engineering? I'm using <cfg2hbm> to generate the hbm.xml files. Can I put the extra xml snippet into hibernate.properties somehow, so that <cfg2hbm> will use it?

#3: In middlegen, the generator is supplied as an argument, as follows:

Code:
                <middlegen
                        <hibernate
                                destination="${src}"
                                standardGeneratorScheme="sequence"
                                standardGeneratorArg="{0}_id_seq"
                        </hibernate>
                </middlegen>



In the hibernate tools source file id.hbm.vm, I see this:
Code:

                 <generator class="$property.Value.identifierGeneratorStrategy">
#set ($parameters = $c2h.getIdentifierGeneratorProperties($property))
#foreach($paramkey in $c2h.getFilteredIdentifierGeneratorKeySet($property))
            <param name="$paramkey">$parameters.get($paramkey)</param>
#end
                </generator>


This seems to imply that the same facility is present, but how do I specify the GeneratorStrategy, and the property list?



#4 So, I can override the hbm.xml templates as well as the POJO templates? Is there documentation on how to do this?

Thanks for your prompt reply (and for the updated documentation!)


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