-->
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.  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Adding a new Hibernate tools
PostPosted: Thu Sep 18, 2003 7:51 pm 
Beginner
Beginner

Joined: Thu Aug 28, 2003 7:05 pm
Posts: 20
Hello,

I have started on a Hibernate tool. It is a re-write of the hbm2java tool. My version uses ant and velocity and provides the user with a great amount of control of the generation. It is very easy to extend and can be used to generate almost anything (from DAOs to DDL to struts actions to unit tests)

I was wondering how I open-source it?
- Do I just donate it to the Hibernate project?
- Do I set it up on source forge?
- Can I put it on the hibernate wiki?
- Can I use the hibernate package or should I create my own.
- Can I use other open source code (i.e. from Apache)?
- If I use some Apache source code, should I leave their copywrite at the top of the file or do I just need to include their license file?
- Is their any restrictions on the jars I use (i.e do they all need to be open-source)

Thanks


Top
 Profile  
 
 Post subject: Re: Adding a new Hibernate tools
PostPosted: Fri Sep 19, 2003 2:45 am 
Hibernate Team
Hibernate Team

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

I have started on a Hibernate tool. It is a re-write of the hbm2java tool. My version uses ant and velocity and provides the user with a great amount of control of the generation. It is very easy to extend and can be used to generate almost anything (from DAOs to DDL to struts actions to unit tests)


Cool !

If you want to donate it to the Hibernate project the easist thing is to submit it via jira - and we can together take it from there.

Regarding using other open source code it's quite alright - just don't require something like Tomcat, Jboss or something of that size ;)

Secondly, if you are using some apache source code, you are probably using it as an external jar, right ? You can't INCLUDE apache source code into Hibernate - do you need that anyway ?

And you can primarily only use opensource external jars.
If you need any non-opensource we (and you) can't distribute it.

Now to the questions about your new hbm2java:

- have you used the contributed velocity renderer or is it a totally new implementation ? ;)

If yes - does it support the meta tags ?

Have you rewrote the parser ?

Just very curious on this since i'm actually doing the exact same thing ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 19, 2003 9:48 am 
Beginner
Beginner

Joined: Thu Aug 28, 2003 7:05 pm
Posts: 20
Hello,

I started doing it as a way of getting to know Hibernate. I have done quite a bit of code generation at work (about 2 years worth) and I wanted to try out some new ideas.

Yes, it is a totally new implementation. It is based on Texen (an ant text generation task which uses velocity). I have spent about 16 hrs and have quite a nice generator. It is pretty small and very easy to extend. You have complete control over the templates and I have started putting together a set of tools that can be used in the templates (including java source code formatting).

The architecture is very simple. Use an ant task to run the generator and handle the loading of files, properties, classpath, etc. Use a plug-in parser to parse the hbm file and create a model. Stick the model into a control velocity template which calls other templates to generate the source code. Add a rich set of tools to do things like insert java docs, format code, load files, convert strings, etc.

The features are as follows (many are not yet implemented, but should not take too long):
- Generate text files using a very small, simple wrapper around ant and velocity.

- Powerful execution environment that uses the power of ant to define:
the classpath
scan directories
include / exclude file patterns (see FileSets)
execution arguments and properties

- Have a plug-in parser architecture (so you can write a plug-in that will parse other types of files.) These other parses can be used to parse everything from alternate products config files (switch from ORB to hibernate) to reverse engineering sql and java source to generating struts / web classes.

- Complete control over the files that are generated. Developers should be able to add new templates for things like dao's, unit test, ddl, etc by simply changing a template file.

- Complete control over source format, license text, code standards, etc

For the Hibernate parser (refactored from the existing hbm2java) ...

- A simple model that represents the Hibernate hbm file.

- A rich set of methods (that can be called from velocity) to generate the source.

- The xml as a dom4j model (which can be directly access from velocity.) This allows the generation task to access the very latest config changes without even changing the source code.

- Access to the meta attributes and the ability to easily (no code change to the generator) add your own.

- A rich set of tools in the templates including:
- Files Tools: Read files and write files
- Generator Tool: Load velocity templates, manipulate the context and generate output strings
- MetaAttribute Tool: Manage meta attributes
- String Tools: Format strings, convert strings, etc
- Xml Tools: Access config file elements directly (without any code changes)
- Java Tools: Source code formatting, java element parsing etc

All tools should be easily extendable. Users should be able to add any java class into the context and directly use its methods in the templates.

and finally a set of nice, clean, easy to change templates with features such as:
- Logging

- Regeneration support (Base class which contains 99% of generated code and the actual class which the user can easily extend). We have found it very useful to be able to generate a class over and over without ever effecting the custom code. For example, if you add a new field to the hbm file, you just regenerate over the Base class. Add to this the ability to check which class needs to be generated (date check) and which class has been customised (file attribute check).

- Support for validation and lifecycle interfaces

- xDoclet tags (just because it is so easy and would allow developers to switch from one type of generation to another)

The nice thing with my approach is it is so simple. Almost all my time is spent creating the templates and understanding the hbm file. I hardly have to spend any time working on the generation mechanics. Add to that the fact that it is so easy to extend and there is a large velocity skill base (plus the fact that you can use java classes directly from velocity) makes it a very easy tool to use. The approach is well proven (just check out the number of generation tools on sourcforge that do very similar things)

Hopefully, I will get to alpha stage in the next 2 weeks.

I would love to get your feedback.

Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 19, 2003 11:34 am 
I would love to see the code.
Have you already somewhere to download ?

I was busy writing the same thing.


Top
  
 
 Post subject:
PostPosted: Fri Sep 19, 2003 12:25 pm 
Hibernate Team
Hibernate Team

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

I started doing it as a way of getting to know Hibernate. I have done quite a bit of code generation at work (about 2 years worth) and I wanted to try out some new ideas.


Same reason I entered the hibernate project - by improving hbm2java (then called CodeGenerator)

[qoute]
Yes, it is a totally new implementation. It is based on Texen (an ant text generation task which uses velocity). I have spent about 16 hrs and have quite a nice generator. It is pretty small and very easy to extend. You have complete control over the templates and I have started putting together a set of tools that can be used in the templates (including java source code formatting).

The architecture is very simple. Use an ant task to run the generator and handle the loading of files, properties, classpath, etc. Use a plug-in parser to parse the hbm file and create a model. Stick the model into a control velocity template which calls other templates to generate the source code. Add a rich set of tools to do things like insert java docs, format code, load files, convert strings, etc.
[/quote]

This sounds great!

Quote:
- Generate text files using a very small, simple wrapper around ant and velocity.
[/qoute]

That's texen, right ?

Quote:
- Powerful execution environment that uses the power of ant to define:
the classpath
scan directories
include / exclude file patterns (see FileSets)
execution arguments and properties


hbm2java have this too - at least when invoked via ant.

Quote:
- Have a plug-in parser architecture (so you can write a plug-in that will parse other types of files.) These other parses can be used to parse everything from alternate products config files (switch from ORB to hibernate) to reverse engineering sql and java source to generating struts / web classes.


Sounds very interesting - and the result from these "parses" are available to the other generators...

Quote:
- Complete control over the files that are generated. Developers should be able to add new templates for things like dao's, unit test, ddl, etc by simply changing a template file.


Possible (and done) in hbm2java to...(but this sounds more "streamlined" - great)


Quote:
- A simple model that represents the Hibernate hbm file.

- A rich set of methods (that can be called from velocity) to generate the source.


Sounds cool too ;) I can't wait how the model is structured - it has been one of my big "challenges" as it should be simple, efficient and flexible enough to be easy to update with any new changes in hibernate core.

Quote:
- The xml as a dom4j model (which can be directly access from velocity.) This allows the generation task to access the very latest config changes without even changing the source code.


That is a brilliant (and simple) solution for handling my "challenge" ;)

Quote:
- Access to the meta attributes and the ability to easily (no code change to the generator) add your own.
[/qoute]

Add your own ? Sounds spookey - but probably usefull in some situations ;)


Quote:
- Regeneration support (Base class which contains 99% of generated code and the actual class which the user can easily extend). We have found it very useful to be able to generate a class over and over without ever effecting the custom code. For example, if you add a new field to the hbm file, you just regenerate over the Base class. Add to this the ability to check which class needs to be generated (date check) and which class has been customised (file attribute check).


This is already in hbm2java - it's one of the main reasons for <meta>!
I hope/wish you would use the existing way to define it since it allows for really flexible control on this generation....

Quote:
- Support for validation and lifecycle interfaces


By support you mean it provides a default implementation of it or ?

Quote:
- xDoclet tags (just because it is so easy and would allow developers to switch from one type of generation to another)


This is golden! It has been of high priority in a long time!

Quote:
The nice thing with my approach is it is so simple. Almost all my time is spent creating the templates and understanding the hbm file. I hardly have to spend any time working on the generation mechanics. Add to that the fact that it is so easy to extend and there is a large velocity skill base (plus the fact that you can use java classes directly from velocity) makes it a very easy tool to use. The approach is well proven (just check out the number of generation tools on sourcforge that do very similar things)


All of this is of course true - (but I would say the same thing about hbm2java, one does not need to think about the generation mechanisms - at least not what I know ;)

Quote:
Hopefully, I will get to alpha stage in the next 2 weeks.

I would love to get your feedback.

Cheers


If you got any chance of submitting this stuff to the JIRA immediatly it would be GREAT! Large parts of The Hibernate team will be together in real life (for the first time ever) at JAOO in Denmark and it would be great to talk about this new and improved hbm2java contribution.

I can handle any state of the code ;) I would just love to see it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 19, 2003 5:27 pm 
Beginner
Beginner

Joined: Thu Aug 28, 2003 7:05 pm
Posts: 20
Hello,

I would love to share the code with the Hibernate team (and anyone else who is interested). I will spend a day or two cleaning / documenting it and then send it to you.

Yes, it is based on Texen, but I have extended it and cleaned up the code. (OK, developers can never leave anything alone)

Quote:
Sounds very interesting - and the result from these "parses" are available to the other generators...


At the moment I have a simple hbm parser. But there is nothing to stop you writing a simple parser that chains / invokes other parsers or even parses different types of xml files

Quote:
- Complete control over the files that are generated. Developers should be able to add new templates for things like dao's, unit test, ddl, etc by simply changing a template file


The nice thing is the templates look almost like the final java files.

Quote:
This is already in hbm2java - it's one of the main reasons for <meta>!
I hope/wish you would use the existing way to define it since it allows for really flexible control on this generation....


Not sure if it is in the version of hbm2java I have seen Hibernate 2.1 b1.
I will try use the existing way. I am note sure if hbm2java generates all files or only the ones for the xml that has changed. I normally mark all generated files as "read-only". That way the user (1) is reminded that the java is generated and should not be altered lightly (2) if changed to write-able, the generator does not overwrite it (a bit backwards, but works like a charm with IDEs and CVS)

Quote:
All of this is of course true - (but I would say the same thing about hbm2java, one does not need to think about the generation mechanisms - at least not what I know ;)


If you look at hbm2java, the renderers are quite large classes. With velocity, these disappear and you can spend the time on other (more interesting) parts of the system.

Quote:
I can handle any state of the code ;) I would just love to see it.


As I said at the start, give me a day or two to clean it up. I will then send it to you. Maybe we could even pair on the development. Particularly as I am very new to Hibernate and it takes me a long time to figure out how to parse the hbm file and what the resulting template should look like. However, the velocity / ant / code generation part I can do in my sleep.

Cheers






[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 19, 2003 5:40 pm 
Hibernate Team
Hibernate Team

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

I would love to share the code with the Hibernate team (and anyone else who is interested). I will spend a day or two cleaning / documenting it and then send it to you.


great - but it would really be nice if could just get a glimpse of it - after tomorrow it's going to happen a 1000's things the next 5-6 days and here i probably can't find much time to look at it......but then again, it is also fully ok if you don't feel like sharing it yet ;)

Quote:
Quote:
Sounds very interesting - and the result from these "parses" are available to the other generators...


At the moment I have a simple hbm parser. But there is nothing to stop you writing a simple parser that chains / invokes other parsers or even parses different types of xml files


cool

Quote:
Quote:
- Complete control over the files that are generated. Developers should be able to add new templates for things like dao's, unit test, ddl, etc by simply changing a template file


The nice thing is the templates look almost like the final java files.


yes - it's one of the good wins.

Quote:
Quote:
This is already in hbm2java - it's one of the main reasons for <meta>!
I hope/wish you would use the existing way to define it since it allows for really flexible control on this generation....


Not sure if it is in the version of hbm2java I have seen Hibernate 2.1 b1.


It is - it was the first tag for <meta> ;)
Look at meta attribute "generated-class"

Quote:
I will try use the existing way. I am note sure if hbm2java generates all files or only the ones for the xml that has changed.


Currently it generates for all the .xml files you give it.

Quote:
I normally mark all generated files as "read-only". That way the user (1) is reminded that the java is generated and should not be altered lightly (2) if changed to write-able, the generator does not overwrite it (a bit backwards, but works like a charm with IDEs and CVS)


It's cool - and one should not add complety automatically generated files to cvs - one should just add the hbm.xml files, right ?

Quote:
Quote:
All of this is of course true - (but I would say the same thing about hbm2java, one does not need to think about the generation mechanisms - at least not what I know ;)


If you look at hbm2java, the renderers are quite large classes. With velocity, these disappear and you can spend the time on other (more interesting) parts of the system.


Yes - and it's why I was about to add the contributed velocity renderer, so we would not require people to code/compile stuff to make changes to the generated code.

Quote:
I can handle any state of the code ;) I would just love to see it.


Quote:
As I said at the start, give me a day or two to clean it up. I will then send it to you. Maybe we could even pair on the development. Particularly as I am very new to Hibernate and it takes me a long time to figure out how to parse the hbm file and what the resulting template should look like. However, the velocity / ant / code generation part I can do in my sleep.


Sounds great - looking forward to it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 20, 2003 11:40 pm 
Beginner
Beginner

Joined: Thu Aug 28, 2003 7:05 pm
Posts: 20
Hello,

My re-implementation of hbm2java is all zipped up and ready to send. It is in the very, very early stages of development but I think it will give you an idea of its direction. I have taken out all the jars (and just left a list of them in the directory instead). It is about 250k. How should I send it to you? I would prefer sending it directly (as I do not want to release the code just yet).

Cheers


Top
 Profile  
 
 Post subject: It sounds very very very good!
PostPosted: Mon Sep 22, 2003 8:23 am 
Newbie

Joined: Thu Sep 04, 2003 10:27 pm
Posts: 3
I'm just beginning to write some tools that can be used in Eclipse or some other IDE like that.

Waiting for download!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 22, 2003 11:29 am 
Hibernate Team
Hibernate Team

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

My re-implementation of hbm2java is all zipped up and ready to send. It is in the very, very early stages of development but I think it will give you an idea of its direction. I have taken out all the jars (and just left a list of them in the directory instead). It is about 250k. How should I send it to you? I would prefer sending it directly (as I do not want to release the code just yet).

Cheers


Just send it to me directly - max AT hibernate.org

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 5:36 pm 
Newbie

Joined: Fri Sep 26, 2003 4:38 pm
Posts: 2
I would love to know more about/see this thing. It is exactly what I had in mind to replace our homegrown O/R generation-from-db-solution (done before middlegen was around). hbm2java is great, but I sometimes need more flexibility in the code generation. I assume it would be fairly easy to extend to generate basic DAO wrappers for the persistables, or is there a way to do that today?

Anxiously awaiting a look-see, Max.

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 27, 2003 6:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it is possible to day - just make your own Renderer ;)

...that said, hbm2java will be extended so it supports/is velocity driven.

I've got a look at the "new" hbm2java stuff and I like the ideas, but it does not handle all the special cases that the current hbm2java does.

So, what I see is that the new ideas will be integrated into the current hbm2java in the nearest future - so we will get the best from both worlds.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 29, 2003 7:52 am 
Newbie

Joined: Fri Sep 26, 2003 4:38 pm
Posts: 2
Yeah - I am looking at doing my own renderer. I will wait for Velocity version to become available, and will create (contribute if anyone is interested) a DAO template.

Nice work, all.

Mike


Top
 Profile  
 
 Post subject: hbm2java new source, XDoclet?
PostPosted: Thu Oct 16, 2003 5:45 pm 
I have seen a number of references to hbm2java generating XDoclet tags. But based on the source and trying it out, can I assume the feature is not yet implemented?

I was curious when we might see GavinLas's source or a merged version. Our team is about to start coding with Hibernate. I have put together a How-To process for using Hibernate on our project, taken primarily from, and with links to, the wonderful doc on the Hibernate web site. The XDoclet enhanced hbm2java tool would make it easy for our developers who are not familiar with Hibernate.

In terms of background, we are doing bottom up: database -> hbm -> java/xdoclet. Throw away the intermediate hbm.xml. We plan on refactoring the ugly DB2 names to nice class and property names in our IDE of choice. In our Ant build script, XDoclet will then generate the hbm.xml files.

Please let us know. The whole Velocity template approach sounds great.

Fred.


Top
  
 
 Post subject:
PostPosted: Thu Oct 16, 2003 9:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
XDoclet from hbm2java is high on the TODO list. Max is rather busy at the moment though be assured it is important. The new velocity backend option could well make this easier to provide.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 17 posts ]  Go to page 1, 2  Next

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.