I've restricted access to the eclipse market place and a network with terrible connectivity issues , therefore i wont be able to download Jboss tools which is like more than 300MB .
Is there a way to generate jpa/hibernate model classes from database without using JBoss hibernate tools ?
yes, it is possible to generate hibernate/jpa specific model classes from you database using hibernate maven plugin. Only thing is your project should be maven project.
Please refer below links:
In the below link plz check the first answer provided by John citizen.
[https://developer.jboss.org/message/801478?_sscc=t#801478][1]
below link for any trouble shooting.
How to configure maven hbm2hbmxml and hbm2java to run one after the other in mvn clean install
Are there no option to generate tables from entities in IntelliJ? Using JPA and eclipselink as implementation. Trying to generate tables for MySQL. All I see is options for importing.
Do I have to use Eclipse to generate tables?
I believe it is not possible in IntelliJ. As far as I remember from a project 1.5 years ago, we didn't use any exporting to database, everything was done automatically upon deploy to JBoss.
Hope this helps.
I am using the eclipse hibernate tools plug-in to reverse engineer my database.
I spent my whole day looking for how to force the DAO generator to use HQL/Criteria with the session factory, transaction, etc.
Right now, if I have the table TABLE in my database, I obtain the DAO class TableHome. This class uses the persistence EntityManager.
I found tutorials using an older version of hibernate tools generating TableDAO instead, and this is what I exactly need.
Thank you very much.
Whether you're using Eclipse or not is unclear but if you are, maybe check if the Console Configuration used by the Code Generation module is not configured for JPA:
alt text http://docs.jboss.org/tools/2.1.0.Beta1/hibernatetools/html/images/plugins/plugins_2.png
See also
Section 3.4. Creating a Hibernate Console Configuration
Section 3.5. Reverse Engineering and Code Generation
Use Salto-DB Eclipse plugin. It comes with all the stuff.
When developing a new project I often want to re-create the schema to apply any new entities or relationships created. I like using hibernate tools in eclipse, but it's a pain when wanting drop and re-create the schema - since it seems to maintain open connections to the db (postgres in this case).
Does anybody know if there is an easy way of getting the eclipse hibernate tools plugin to close off all connections?
It might be helpful to tell you, that i was using Hibernate Tools for creating the schema, too. I never had the problem you are describing. Nowadays i use liquibase for schema migration. It is a different approach, but i like it.
I'v never hit this problem before, but we use Maven run from the command line to create/update the schema and also DBUnit to upload data. Then back to elcipse...
I'm looking for a general solution for upgrading database schema with ORM tools, like JPOX or Hibernate. How do you do it in your projects?
The first solution that comes to my mind is to create my own mechanism for upgrading databases, with SQL scripts doing all the work. But in this case I'll have to remember about creating new scripts every time the object mappings are updated. And I'll still have to deal with low-level SQL queries, instead of just defining mappings and allowing the ORM tools to do all the job...
So the question is how to do it properly. Maybe some tools allow for simplifying this task (for example, I heard that Rails have such mechanism built-in), if so please help me decide which ORM tool to choose for my next Java project.
LiquiBase is an interesting open source library for handling database refactorings (upgrades). I have not used it, but will definitely give it a try on my next project where I need to upgrade a db schema.
I don't see why ORM generated schemas are any different to other DB schemas - the problem is the same. Assuming your ORM will spit out a generation script, you can use an external tool to do the diff
I've not tried it but google came back with SQLCompare as one option - I'm sure there are others.
We hand code SQL update scripts and we tear down the schema and rebuild it applying the update scripts as part of our continuous build process. If any hibernate mappings do not match the schema, the build will fail.
You can check this feature comparison of some database schema upgrade tools.
A comparison of the number of questions in SOW of some of those tools:
mybatis (1049 questions tagged)
Liquibase (663 questions tagged)
Flyway (400 questions tagged)
DBDeploy (24 questions tagged).
DbMaintain can also help here.
I think your best bet is to use an ORM-tool that includes database migration like SubSonic:
http://subsonicproject.com/2-1-pakala/subsonic-using-migrations/
We ended up making update scripts each time we changed the database. So there's a script from version 10 to 11, from 11 to 12, etc.. Then we can run any consecutive set of scripts to skip from some existing version to the new version. We stored the existing version in the database so we could detect this upon startup.
Yes this involved database-specific code! One of the main problems with Hibernate!
When working with Hibernate, I use an installer class that runs from the command-line and has options for creating database schema, inserting base data, and dynamically updating the database schema using SchemaUpdate. I find it to be extremely useful. It also gives me a place to put one-off scripts that will be run when a new version is launched to, for example, populate a new field in an existing DB table.