Working with Hibernate and IntelliJ - how to's ??

This is a discussion on Working with Hibernate and IntelliJ - how to's ?? within the J2EE forums in Framework and Interface Programming category; Hi, I want to start with my business object model, define the OR-Mapping with JPA-annotations and generate my database tables from there. Is this supported from IntelliJ? I couldn't find anything in the documentation. How are other users accomplishing this task, which tools do you use for this from within IntelliJ? Kind regards and thanks Thomas Gülden Munich, Germany...

Go Back   Application Development Forum > Framework and Interface Programming > J2EE

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 11-11-2007, 02:13 PM
=?UTF-8?Q?Thomas_G=C3=BClden?=
Guest
 
Default Working with Hibernate and IntelliJ - how to's ??

Hi,

I want to start with my business object model, define the OR-Mapping with JPA-annotations and generate my database tables from there. Is this supported from IntelliJ? I couldn't find anything in the documentation.

How are other users accomplishing this task, which tools do you use for this from within IntelliJ?

Kind regards and thanks

Thomas Gülden
Munich, Germany
Reply With Quote
  #2  
Old 11-11-2007, 03:44 PM
Stephen Friedrich
Guest
 
Default Re: Working with Hibernate and IntelliJ - how to's ??

Hallo Thomas,

don't know if there's a better way, but here's what I usually do:

Be sure to add both JPA and Hibernate facte to the project - the latter
only if you want to use hibernate extensions to JPA, like functions in
"order by" clause, like order by lower(name).

Write your annotated classes.

During development I test with hibernate's auto-schema-creation on and
have the import.sql create initial data.

Later, I use this helper class to generate the schema's DDL:

/**
* Generates DDL using the JPA entity definitions. SQL statements are printed to console and saved into a file named
* schema.sql (in the current working directory).
* BEWARE: Do not directly use the generate table definitions. Please review and at least change foreign keys names
* into something more meaningful (like FK_PARAMETER_2_CALC_RULE) than the defaults (like FKDC9142E99711833E).
* Note that oracle has length limit for names (columns, tables, foreign keys) of 30 characters.
*/
public class DbSchemaGenerator {
private DbSchemaGenerator() {
}

public static void main(String[] args) {
AnnotationConfiguration configuration = new AnnotationConfiguration();

// Select the dialect matching the selected DBMSs

//configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.Oracle9Dialect");

// Add all root packages that contain entities
configuration.addPackage("com.acme.foo

// Add each entity
configuration.addAnnotatedClass(Authorization.clas s);
...

// Dump formated SQL to console and file
SchemaExport schemaExport = new SchemaExport(configuration);
schemaExport.setOutputFile("schema.sql");
schemaExport.setFormat(true);
schemaExport.setDelimiter(";");
schemaExport.execute(true, // write schema to output
false, // do not export to DB
false, // no drop statements
true // only create statements
);
}
}


Thomas Gülden wrote:
> Hi,
>
> I want to start with my business object model, define the OR-Mapping with JPA-annotations and generate my database tables from there. Is this supported from IntelliJ? I couldn't find anything in the documentation.
>
> How are other users accomplishing this task, which tools do you use for this from within IntelliJ?
>
> Kind regards and thanks
>
> Thomas Gülden
> Munich, Germany

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:36 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.