-->
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: Editing generated Middlegen .hbm.xml files
PostPosted: Mon Nov 17, 2003 11:50 am 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
Hi All,

There are a number of properties that the Middlegen plugin does not include, such as JCS and other caching tags, dynamic-update and dynamic-insert, etc. I can manually edit the generated .hbm.xml files to include what I need, but then I lose the ability to regenerate the files if the db schema changes at all, e.g. if I add a column to my table, I cannot automatically regenerate the hbm.xml file, but I would need to manually add it in. This makes the middlegen generator much less useful.

Is there a way to specify to middlegen custom properties? A good way I can think of is to have an optional property in the ant task in which I can place whatever custom xml markup I would like to add. Is there anything like this? Or to be able to include a file with custom props in it.

Another way I was thinking of is to write a program that parses the hbm file and adds in what I need. Or to create an XSL process to transform the xml. This is obviously not an ideal way to accomplish this though, and much more work that I think should be needed.

Anyone have any ideas or thoughts on this?

Thanks,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 8:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
It is true that Middlegen does not support every possible option but it does provide the bulk of them.
Now having said that, you can request enhancements (I am listening) and or make appropriate changes and send to me. The three you have asked for are reasonable (at least the cache tag not JCS as its depricated). I have added them to my r4 TODO list.
For the moment, I am helping out with Middlegen v2.0 final as v3.x looks to be some time away.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 10:45 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
Ok.

Note though that I intended a broader customization capability that just those three items. For instance, say I want to construct the class to use a component. From what I can tell the Middlegen plugin does not generate the xml for components, such as this from the reference guide:

<component name="Name" class="eg.Name"> <!-- class attribute optional -->
<property name="initial"/>
<property name="first"/>
<property name="last"/>
</component>


Another example are some attributes in the <class> tag that are not supported, such as:

dynamic-insert="true" and polymorphism="implicit" and where="arbitrary sql where condition"

Same goes for caching tags, and others.


now my idea is for the user to be able to specify any markup they wish, and the generator would simply put in whatever text they specify in the appropriate place. There would be placeholders where the user can optionally add markup, such as a <class> attribute placeholder and a <class> other element placeholder. I could then create an xml file such as this:

<customadditons>

<classAttribs>
dynamic-insert="true"
polymorphism="implicit"
where="arbitrary sql where condition"
</classAttribs>

<OtherClassElements>
<![CDATA[
<component name="Name" class="eg.Name"> <!-- class attribute optional -->
<property name="initial"/>
<property name="first"/>
<property name="last"/>
</component>
]]>
</OtherClassElements>

</customadditions>

This xml file could then be referenced somehow in the <table> elements in the build.xml file that runs Middlegen. The generator would then insert whatever markup the user defined in the appropriate place.

If you want to get really fancy, you could even have placeholders to edit text in association elements, map elements, property elements, etc. You would just need to specify the name of the association, map or property, and the generator would match them appropriately and add in the custom attribs and/or elements.

I think all this would be very useful, and is really the only way to have a generator that keeps editing changes.

Does anyone have any thoughts or further ideas? Also, does anyone perhaps know of any XML tools that could perhaps do postprocessing on an xml file and do similar tasks to what I outlined?

Thanks,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 9:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Some of what you are asking is easy enough and others are quite difficult to in Middlegen as the tools stands today. It is being re-architected but I am not totally aware of the goals (its going along the lines of XDoclet 2). For the moment post processing maybe your best option. I have always cut the code to perform the XML manipulation. Your ideas are great - like to hear how you get on.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 10:18 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
david wrote:
Some of what you are asking is easy enough and others are quite difficult to in Middlegen as the tools stands today. It is being re-architected but I am not totally aware of the goals (its going along the lines of XDoclet 2). For the moment post processing maybe your best option. I have always cut the code to perform the XML manipulation. Your ideas are great - like to hear how you get on.


Just want to thank the Middlegen author for the great work. The R2 had some issues that needed correcting. The R3 is much better. Congratulations.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 10:45 am 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
I agree with nerotnt, the Middlegen and plugin teams did great work. My comments and ideas are simply extensions to make the tool even more useful and was not intended to diminish their work.

I think post processing is the way to go, though I fear that if I would ever want to migrate to a later version of the plugin (whenever they get released) it may break the xml and require major reworking. Hmm. I will need to think about all this a bit more.

Another way I was thinking of to solve these problems would be for Hibernate to have the concept of a "xml file hierarchy", something like an ability to "extend" a "super" file. The extended file could add or override anything in the super file. Something like extending classes in java. So a subfile would extend the file generated by middlegen, adding on whatever attribs and elements needed. Perhaps an idea for a future version of Hibernate.

Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 7:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Thank you both for positive comments. The middlegen hibernate plugin user community is growing like I had not expected. I appreciate people going to the effort to send great ideas and (positive and constructive negative) feedback. It will all go to making the tool better for all of the community. I hope (and expect) the plugin to keep improving. Daniel has looked into the future and has rightly identified areas that would be fantastic to implement. Over time, I think the tools side of hibernate will keep growing. I have had a number of email coversation asking for a major IDE effort to bring all the tools into a integrated development environment. I hope this can happen - its a matter of time.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 8:21 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
Quote:
I have always cut the code to perform the XML manipulation


David, could you please be more specific what methods you used to perform the XML manipulation?

Thanks,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 11:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
When ever I have needed to manipulate XML I have tended to use JDom but its progress has slowed and I am not sure of its future. Its advantage is that its easy to modify the DOM and generate the XML. I have looked at dom4j and its look very good with XPath support etc. The project appears active so this is where I would start. In anycase, some of the more advanced mapping requests might just be do able. When I get a bit of a break (very busy at the moment) I will have a shot at it.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.