Hello everyone,
I am quite new to hibernate and managed to generate DAOs and POJOs using reverse engineering. My current setup sadly does not generate separate java classes for composite IDs.
I should mention, that I only use the reveng.xml to reverse engineer and generate: - DAOs - POJOs - hibernate xml mappings So in this case, I cannot define a hibernate mapping file *.hbm.xml to specifiy the composite-id.
I found, that if I setup the generic exporter using for_each: component, that this generates my missing ID-classes. But I really need component AND entity. The hibernate tools have a default, which says: for_each: component, entity. I would have thought, that this will generate both. Executing this gives me an error on generating the POJOs: Exception while generating code - Reason: org.hibernate.too.hbm2x.ExporterException: for-each does not support [ entity]
I would like to point out, that there seems to be a blank between the bracket [ and the value "entity". Is this a bug or do I have to create two console configurations with each having its own generic exporter. One setup with for_each: entity, the other with for_each:component? I currently did just that and it seems to work. But maybe there is a better way? What I have: My current reveng.xml looks like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering> <table-filter match-schema="ADMIN" match-name=".*" package="mypackage.hibernate.admin" /> <table schema="ADMIN" name="ASSIGMENTS" class="mypackage.hibernate.admin.Assigments"> <primary-key> <key-column name="USERNAME" property="username"/> <key-column name="SITE" property="site"/> <key-column name="ALLOWED_ROLE" property="allowedRole"/> </primary-key> </table> </hibernate-reverse-engineering>
Additionally, I generated DDL using the eclipse DTP-plugin to show this table as an example: --<ScriptOptions statementTerminator=";"/>
CREATE TABLE ADMIN.ASSIGMENTS ( USERNAME VARCHAR2(20) NOT NULL, SITE VARCHAR2(50) NOT NULL, ALLOWED_ROLE VARCHAR2(30) NOT NULL, LAST_MODIFIED DATE DEFAULT sysdate );
CREATE UNIQUE INDEX ADMIN.PK_ASSIGMENTS ON ADMIN.ASSIGMENTS (USERNAME ASC, SITE ASC, ALLOWED_ROLE ASC);
ALTER TABLE ADMIN.ASSIGMENTS ADD CONSTRAINT PK_ASSIGMENTS PRIMARY KEY (USERNAME, SITE, ALLOWED_ROLE);
ALTER TABLE ADMIN.ASSIGMENTS ADD CONSTRAINT FK_ASSIGMENT_USER FOREIGN KEY (USERNAME) REFERENCES ADMIN.USERS (USERNAME) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE ADMIN.ASSIGMENTS ADD CONSTRAINT FK_ASSIGMENT_SITE FOREIGN KEY (SITE) REFERENCES ADMIN.SITES (NAME) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE ADMIN.ASSIGMENTS ADD CONSTRAINT FK_ASSIGMENT_ROLE FOREIGN KEY (ALLOWED_ROLE) REFERENCES ADMIN.ROLES (NAME) ON DELETE RESTRICT ON UPDATE CASCADE;
What I would like as generation output: a class Assigments, with the following fields: // Fields /** AssigmentsId.*/ private AssigmentsId assigmentsId; /** Users. */ private Users users; /** Sites. */ private Sites sites; /** Roles. */ private Roles roles; /** lastModified. */ private Date lastModified;
a separate class named AssigmentsId, with the following fields: /** username. */ private String username; /** site. */ private String site; /** allowedRole. */ private String allowedRole;
Using google and forum search, I only found information on how to use this when manually providing the hibernate mapping files (*.hbm.xml) or jusing the javadoc method. Any help is warmly welcomed! Thanx in advance!
Additional information about my current setup: * Oracle 10g enterprise edition database * Suse Linux Enterprise Edition (SLES) 11 (64bit) with Service Pack 2. * Eclipse IDE (Indigo) Version: Indigo Release Build id: 20110615-0604 * java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) * JBoss Hibernate Tools Version: 3.4.0.v20120307-2104-H60-Beta1
I connect to the database using an Oracle Thin Driver provided with a jar: /u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6_g.jar. Within Eclipse (using DTP), I get the following information about the driver: Oracle: 0.2.0.1.0 - 64bit Production The following technologies are available on the server: JDBC: 11.2.0
On opening my driver-jar, I have the following info within the Manifest: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.6.5 Created-By: 1.5.0_24-rev-b08 (Sun Microsystems Inc.) Implementation-Vendor: Oracle Corporation Implementation-Title: JDBC debug Implementation-Version: 11.2.0.2.0 Repository-Id: JAVAVM_11.2.0.2.0_LINUX_100812.1 Specification-Vendor: Sun Microsystems Inc. Specification-Title: JDBC Specification-Version: 4.0 Main-Class: oracle.jdbc.OracleDriver sealed: false
Name: oracle/sql/converter/ Sealed: false
Name: oracle/sql/ Sealed: false
Name: oracle/sql/converter_xcharset/ Sealed: false
|