The latest version of Middlegen is now available, with numerous enhancements and bug fixes, including:
What is Middlegen
- Hibernate plugin - enhancements, bug fixes and upgraded to include hibernate 2.1 features.
- Torque plugin (new) - generate Torque config files.
- XMI plugin (new) - generate some XMI diagrams from the generated code.
- Adapter plugin (new) - making it easier to switch persistence layer for generated Struts/JSP code.
- Many core/plugin bugs fixed.
Middlegen provides targeted code generation plugins that process an existing database design, after optionally fine tune the settings, then Middlegen generates directly (or indirectly using additional tools and processes) all the repetitive, tedious to write code and configuration files for you.
If you already have a database, you can use Middlegen to generate...
The Middlegen plugin API allows the provided plugins to be extended and customized. In addition, new plugins can be created to extend Middlegen hence reduced your development time.
- Persistance layer with EJB (CMP 2.0)
- Persistance layer with Hibernate 2.x
- Persistance layer with Torque
- Persistance layer with JDO 1.0
- Database GUI with JSP/Struts
- XMI data model for UML modeling and manipulation
- Database schema documented in a HTML format
The project welcomes several new committers who have joined the project. Expect many new features in the future with a reduction in time between our releases cycles.
The refer to the Middlegen home page
for further information. The source and binaries can be downloaded from here
Of all these XDoclet/JavaDoc based productivity tools coming out, I did not find a single tool that supports both WLS 8.1 and Websphere 5.1.
XDoclet - still supports only WLS 6.0/7.0
Middlegen - no support for Websphere
EJBGen - Only supports WLS
Support for special products is usually added by someone in need of that support. There is some kind of support for WebSphere in XDoclet, my guess is that it's pretty straightforward to extend this to support latest versions. Same for Weblogic.
Once that is added to XDoclet, it's very easy to include it in Middlegen. Just specify what XDoclet tags you need, and the developers will include it.
Support for special products is usually added by someone in need of that support.
In other words, it's opensource.
Another point worth noting is the support for other persistence mechanisms like Hibernate and Torque. These do not require any special container. For new projects I'd go for Hibernate together with Spring or similar lightweight frameworks.
The CMP plugin is just one of four different persistence plugins supported by Middlegen (others being Hibernate, Torque, JDO).
I have been interested in using Middlegen for a while now and keep hoping with each release they will come up with better documentation or an easier way to configure the thing. I've probably looked at it many times and each time I end up throwing my hands up and removing it from my machine. I've never had the time to figure out how to get it to work. In my opinion, it looks like a very useful tool, but until it gets better documentation and easier configuration, I'll never add it to my toolset and I would imagine I'm not the only one who feels this way. Maybe it just looks hard to configure because I can't seem to round up enough documentation to put it all together. Then again maybe I'm just impatient and critical.
I have been interested in using Middlegen for a while now and keep hoping with each release they will come up with better documentation or an easier way to configure the thing. I've probably looked at it many times and each time I end up throwing my hands up and removing it from my machine. I've never had the time to figure out how to get it to work. In my opinion, it looks like a very useful tool, but until it gets better documentation and easier configuration, I'll never add it to my toolset and I would imagine I'm not the only one who feels this way. Maybe it just looks hard to configure because I can't seem to round up enough documentation to put it all together. Then again maybe I'm just impatient and critical. Nic
Middlegen has been more difficult than necessary to get up and running. One of the goals for the next release is to make this easier out of the box.
We welcome any suggestions that you may have that would make middlegen easier to utilize in your next project. Please add specific comments here or add an RFE and we will work to get it in the next release.
Agree that config is a big hassle. Some things I'd like to focus on for the next release (~2-3 months from now):
* More default values, making more config parameters optional.
* Detach from Ant, right now it's way too tightly tied to the Ant task.
* Pull the Middlegen generated stuff away from XDoclet, Hibernate tools and other tasks. They are important, but tend to clutter the understanding of what Middlegen actually does itself.
* Build smaller and easier to understand examples. The current example consist of a gigantic Ant build file that pretty much runs all plugins with all possible parameters and options, half of it only being relevant for the CMP generation.
* Finish a Maven plugin, with more default parameters (ref. my first + second points), that will work much like the current XDoclet plugin for Maven.
* Better, smaller and more to-the-point documentation.
The core configuration is basically setting up the JDBC parameters (which is not always easy but there is little that can be changed here). The rest is setting up the required plugins. I have periodically released a hibernate specialist package on the hibernate SF download (current release there is R5) which has a simple example already setup with a small HSQL database. Set up Ant and your classpath and your ready to use it.
Having said that your feedback on what you have found difficult or frustrating is important and will be given serious consideration.
I agree with Nic. Middlegen is indeed difficult to configure. I've also been looking for a good code generator for my projects. Middlegen was one of the first projects I discovered but never managed to keep on using it.
Look for example how the guys of Firestorm DAO are doing some things. They have a nice written GUI tool for generating a DAO layer which is very easy to configure and use (despite of the lacking documentation).
I'll keep following the development of Middlegen and hope that the next version will be intuitive and easy to configure.
Wish you much success in your work.
did anyone ever compare Middlegen to AndroMDA (http://team.andromda.org/docs
especially on these points:
1) extensibility (adding features ...)
2) changeability (customization ...)
3) setup cost/effort
4) quality of generated code (not only coding style but also patterns, consistency, overhead, ...)
5) standardization (XMI, J2EE specs, ...)
The two projects have quite different focus AFAIK. AndroMDA generates code based on UML diagrams/XMI models, a very top-down
approach where you might end up with a generated database in the end. Middlegen on the other hand is based on an already existing database, the bottom-up
, and generates code from this. Also I'd say that Middlegen is much more specific, it generates a persistencelayer and the rest is pretty much left up to the developers. AndroMDA on the other hand seems to be more of a full MDA tool controlling the entire project through all layers.
I also think the two tools could coexist in the same project, using Middlegen to generate the persistence layer and AndroMDA to model the rest of the application (web actions or other clients to the persistence layer).
The Hibernate team has an interesting approach to the Roundtrip Development, where both Middlegen and AndroMDA are mentioned as part of the "toolbox":http://www.hibernate.org/102.html
I've experimented with both on quite a few occasions but never made full use of either within a project.
I was about to suggest that there is a lot duplication with the Cartridges (AndroMDA) and the Plugins in Middlegen and that it might be worth working together on these. Surly the generation of EJB's, Struts, JDO's and other stuff is much the same once you have a plan.
That was before I noticed that AndroMDA now has a new component that allows it to create a XMI model (UML I think) from a database scheme called Schema2XMI. This is similar to what Middlegen is trying to do but with the addition that you get to see your object model with your favourite UML package.. Note: Haven't actually had a go.. Just spotted it on their new site. Might be back later to compare findings...
The use of a package specifically written to show object/table graphs could befit Middlegen. I have used it on a database with over 75 tables and the GUI was impossible to use..
BTW I have no affiliation with either project... I just enjoy it when most of your development gets done for you. :-)
I agree that you need to dig into the directory structure to find the
Firestorm DAO documentation. It's good if you can find it.
There is a tutorial with screenshotslink
Murat eclipste middlegen i nasıl kullanıyoruz. hibernate kısmında sorun cikmiyor ama struts olayını halledemedim .. bu konuda bilgin varsa bana anlatabilirmisin
Is middlegen still moving to Codehaus?
Middlegen will no longer be moving to codehaus. It will be staying on the SourceForge Site. Codehaus did not meet our needs at this time. All open issue on codehaus will be moved to SF and the SF bug list will be reopened.
I'm using hibernate 2.1, Middlegen 2.1, MySQL 4.0.20d with MyISAM tables, mysql-connector-java-3.0.15-ga, ant 1.6.2, Linux 2.4.21-4.EL and everything seems to work fine. The gui comes up and I can view the tables of my database. Problem is the relationships are not visible. I ran ant with the verbose flag and the following message was logged:
"WARNING: Middlegen couldn't find any relations between any tables."
I've noticed some posts in the forum that think the Driver may be the issue, but I'm using the latest jdbc driver available from the MySQL site. Also, I will NOT be able to convert the tables from MyISAM to InnoDB, so unfortunately I cannot consider this fix which is mentioned on the Middlegen site. Is there anyway around this using Middlegen or possibly another tool similiar to Middlegen or should I go ahead and generate the Hibernate mapping files by hand?
Thanks for using the tool. This question is best directed to the forums. I did answer one on the hibernat eforum almost exactly the same. Anyway, this is documented on the web site. Here is a portion of the section on mySQL.
Requires MySQL 3.23.43b (or higher) with InnoDB enabled and MM.MySQL 2.0.9 or higher. The table names must be define in lower case, otherwise no relations will be discovered. If you have relations using foreign keys that consist of multiple columns, you should use the driver shipped with Middlegen. It has a bugfix which isn't yet fixed in the official driver.
On Win32 with MySQL 4.0.18 (or higher) + JDBC 3.0.14 (or higher), set lower_case_table_names=2 in my.ini. This will force InnoDB tables to be stored in lower-case, and will solve the above problem with relations discovery. The tables can still be referred to my their upper/proper case names, but will be converted to lower-case during the query. Not tested, but expect that lower_case_table_names to either 1 or 2 on Linux will have similar results.
Tested multi-column FKs with MySQL 4.0.20 and JDBC 3.0.14, and multi-column FKs appeared to work.
Hope this helps.
It's a well known problem, that you need InnoDB to get the relationships. I found the following in the MySQL Connector/J documentation:
Foreign Key information (getImported/ExportedKeys() and getCrossReference()) is only available from 'InnoDB'-type tables. However, the driver uses 'SHOW CREATE TABLE' to retrieve this information, so when other table types support foreign keys, the driver will transparently support them as well.
Guess MyISAM doesn't support foreign keys yet..
What I've done before, is to create a copy of my database with the tables set to InnoDB-type. Bit more work, but still worth the effort.
Middlegen is the best tool ever!
I have just tried to use MG on a small-sized (~15 tables) project that uses CMP 2.0 (not my fault). The DB schema has a few anomalies such as a reflexive NM relationships. The MG generated Code turns out to be non-compilable (method names with dashes, non-declared parameters), and formatting is broken in many places.
There seems to be no way to adapt relationship role names, nor file comment headers and the like. The velocity template is embedded in the jar file and rather complex to edit.
My conclusion is that MG is not usable with CMP.
If you submit a sample relationship/sql that causes the problem to the Middlegen user list (middlegen-user at lists dot sourceforge dot net) or the issue tracker (http://sourceforge.net/tracker/?group_id=36044&atid=415990
), so the problem can be reproduced easily, it would be of great help :)
Focus for the next few months will be to get things cleaned up, and all bugs fixed. Making Middlegen easier to use and with fewer errors in the generated code.
Sorry, just saw your message from yesterday.. Thanks :)
An initial version of the new Maven plugin for Middlegen has been added here:http://boss.bekk.no/boss/middlegen-maven/
Any feedback would be welcome on the user mailinglist (middlegen-user at lists dot sourceforge dot net).
Is there any latest version available in the Middlegen which uses Hibernate 3. Any input is highly appreciated.
so is there a detailed installation / configuration guide?