Java, Code Generation, and Persistence Frameworks

随声附和 提交于 2020-01-01 12:08:55

问题


Are there any Java code generation persistence frameworks? Something that is "database first" rather than object model first? I know this is probably heresy in the Java world, I'd just like to know if any frameworks like this exist.

I'm more of a .NET guy these days. So on the .NET-side tools like .NET Tiers or CSLA come to mind.


回答1:


sure, hibernate and netbeans for example can reverse engineering a database. You may be want to look at:

  • Hibernate Tools; site in maintenance
  • netbeans, with recent version of netbeans you can create JPA entities from a JDBC connection

My 2 cents.




回答2:


The Apache Cayenne ORM framework is able to reverse engineer a database. See here.




回答3:


I developed jOOQ to exactly suit your needs - so don't worry about the heresy :-)

Check out the examples page or an article on dzone illustrating my motivations of creating such a framework. The main advantages are:

  • It generates source code
  • It stays close to SQL by providing a SQL-like DSL in Java
  • It supports easy access vendor-specific features, such as UDT's, stored procedures
  • It supports all advanced SQL features, such as UNIONs, nested SELECTs, aliasing, etc

Note that jOOQ is NOT really an OR-mapper. It focuses on the relational datamodel from your RDBMS and doesn't give you the possibility to create your custom object-oriented domain model like Hibernate or JPA do. This is precisely for the reason you mentioned yourself: Something that is "database first" rather than object model first




回答4:


Checkout EclipseLink project ( plugins for eclipse) , you can generate JPA models from database tables




回答5:


DB Importer is an Eclipse plug-in that generates JPA classes from a database.

Disclaimer: I am the creator of DB Importer.




回答6:


Telosys Tools is a free "database first" code generator

See : https://sites.google.com/site/telosystools/

It's an Eclipse plugin, the templates are customizable if necessary

It can generate the persistance layer (JPA) but also the CRUD Screen ( tutorials are here : https://sites.google.com/site/telosystutorial/ )




回答7:


Many of the Java-based persistence tools include tools to generate code based upon an existing schema. Netbeans will generate JPA (including Session bean facades, if desired). Similarly, JBoss Tools for Eclipse will generate Hibernate JavaBeans for you based upon an existing schema.




回答8:


I would recommend HiberObjects. It's an Eclipse plugin that can be used to model persistent objects or reverse engineer an existing database. The way it lets you set up unit tests is truly awesome. You can also modify how for instance DAO classes are generated: just modify a Groovy script and all DAO-classes are re-generated. I have encountered a few bugs, but the guy behind it has been very responsive and released fixes in short time. A description and user ratings/comments are found at Eclipse Plugin Central.



来源:https://stackoverflow.com/questions/764106/java-code-generation-and-persistence-frameworks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!