-->
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.  [ 11 posts ] 
Author Message
 Post subject: Middlegen plugin standalone?
PostPosted: Wed Dec 24, 2003 12:04 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
I have some ideas I hope to implement in the coming week or so. In particular, I would like to figure out some way to have middlegen and the plugin generate the hbm files without using the GUI at all.

The gui is pretty good, the problem is that my project has 70+ tables and it is nearly impossible to get them all in that little window in the interface! The interface also has no navigation to find tables easily, etc.

I envision being able to specify relationships between tables in one XML file, perhaps in the same ant file used to start up middlegen. Also some other properties, such as sequence names and other essential items. The middlegen plugin would then use these definitions to create the HBM file.

This way I am using the leveraging ability of middlegen to discover table columns and create the actual xml in the hbm files.

Another part of this is being able to tell the plugin the generate through the ant script, not only by pressing "'generate" on the GUI.

Does anyone have any ideas how this can be implemented? I am playing with an idea to manipulate the preferences file to contain the realationships and other info I need . But this seems a messy way to go about this, and also may break with future versions of middlegen.

Cheers,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2003 12:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh - I think most of this is part of the core of middlegen!
Read the middlegen docs - there should be some guides on how to run headless and specify relationships.

You do also know that middlegen can be started in gui mode, make your changes and then save the state so you don't need to start all over again....?

Or am i misunderstanding something here ? ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2003 12:38 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
I have been reading the docs and as far as I can tell you could only specify relationships that are not defined in the db, and many-to-many relationships. But for relationships that are in the db, there is no way to specify if the relationship is one-to-one, many-to-one or one-to-many, as well as unidirectional or bidirectional without using the gui. Or am I reading the docs incorrectly?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2003 7:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
It is designed to run the GUI to fine tune the system, including changing the relationships if needed. There are many defaults (but these are not always appropriate) and in the case of relationships the default is the assume a one-to-many relationship. Once you have fine tuned the mappings with the GUI you don't need to run the GUI (ant task gui="false") to regenerate the mappings.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2003 11:17 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
That is what I thought. I just wish there was some way to specify and tune relationships without the gui.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2003 6:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
drosenbaum wrote:
That is what I thought. I just wish there was some way to specify and tune relationships without the gui.


eh - how about writing the hbm.xml directly then ?
That is what it is for!

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2003 11:11 am 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
A nice feature that middlegen gives you is that if you add or delete columns to any table, the hbm files automatically get updated with these changes. I am on a team with other people and columns get changed all the time. It is not always so easy to keep track of all the changes each member makes. Also, there are fewer steps required when making changes to tables, as I would only have to make my change in the db and it would automatically be reflected in my code as well.

Typically when I play with my data model I would be working with a tool like toad, add a column with it and then write some sample queries to see if it does what I need. In such sessions I may make a number of changes and switch back and forth until I am satisfied with my result. It is pretty distracting to have to keep track and remember all my changes. I should simply have to run "regenerate" after I am done modifying things and be done with it. This is what I had available to me in past projects as well (though admittedly these were with home grown generators. Hibernate offers much more which is why I chose to go with it).

Having to manually manipulate hbm files is one shortcoming of Hibernate from my standpoint. Middlegen offers some promise to fill this void, it just needs perhaps some further modifications to suit my needs.

Thanks,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2003 3:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Ok - i follow. (but please don't call it a shortcoming that you can manipulate hbm.xml's directly - would you rather that they were binary ? ;)

..and i'm sure that David will accept any patches that improves middlegen - hint-hint ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2003 8:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
If your only removing or adding a standard property column then non-gui mode will generate the updated mapping for you. When you add a table or want to change the table relationship, say to one-to-one or uni-directional, then you will need to launch the GUI make the change then exit. The change is now in saved in the preferences store which is used during this and future generation phase processing. Now I would be interested in allowing greater configuration as a part of the Ant task. There is alot there now and I have no problem with the concept of extending the capabilities.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 1:41 pm 
Regular
Regular

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

Let me clarify what I meant. I feel it is a shortcoming specifically that when columns are added and deleted that there is a need to modify the hbm file to update these changes as well. But of course there are many other settings that need to be specified in that file!

I am now playing around with an idea in my head that an hbm could perhaps be divided into two parts: a generated and manual part. The generated part would be the column elements of the table while the manual part contains everything else. I wish it were possible within hibernate to specify these things in two separate files. To get around this though, it would be possible through xml to include the generated file in an <!ENTITY element in the manual file. Thus it may be possible to generate the columns while keeping all other settings separate.

One complication though is the column elements themselves, that if the column is part of a relationship it should not be specified at all. Therefore while generating the column elements there would be a need to parse the manual hbm file to see if any relationships were defined for a particular column, and if so exclude it.

Another downside to this is that a user would have to enter all the relationships by hand, which is unneccesary while using the plugin.

These are still rough ideas but I am still playing with them. This could perhaps even serve as an alternative to using Middlegen. The plugin is good but is proving difficult to use if you have many tables.

Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 3:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
As the hbm.xml is right now (and probably will be forever ;), i see it as more likely that we do like David talks about - enhancing how much is configurable from the middlegen/hibernate ant setup stuff.

Your idea with seperating stuff out in external entities is good for some stuff, but i don't think it will work very well in this scenario - just as you mention.

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