Hello
I'm using Hibernate 3.3.2.GA and an Oracle database
I have two different machines with the same settings when I generate code I get different results.
for an entity, the Hibernate generator changes the order of the arguments of the constructor
Example:
hibernate.cfg.xmlCode:
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@[IP]:[PORT]:DEV26</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">pass</property>
<property name="hibernatetool.metadatadialect">org.hibernate.cfg.reveng.dialect.OracleMetaDataDialect</property>
<property name="current_session_context_class">thread</property>
</session-factory>
sql for table creation - DDLCode:
CREATE TABLE "TRAINNING"."ITEM"
( "ID_ITEM" NUMBER(24,0) NOT NULL ENABLE,
"CODE" VARCHAR2(200 CHAR),
"NAME" VARCHAR2(200 CHAR),
"BLOCKED" VARCHAR2(1 CHAR),
"ID_ITEM_CATEGORY" NUMBER(24,0) NOT NULL ENABLE,
"ID_ITEM_UM" NUMBER(24,0) NOT NULL ENABLE,
"ID_ITEM_STATUS" NUMBER(24,0) NOT NULL ENABLE,
CONSTRAINT "ITM_PK" PRIMARY KEY ("ID_ITEM"),
CONSTRAINT "ITM_BK" UNIQUE ("CODE"),
CONSTRAINT "ITM_IC_FK" FOREIGN KEY ("ID_ITEM_CATEGORY")
REFERENCES "TRAINNING"."_ITEM_CATEGORY" ("ID_ITEM_CATEGORY") ENABLE,
CONSTRAINT "ITM_IUM_FK" FOREIGN KEY ("ID_ITEM_UM")
REFERENCES "TRAINNING"."_ITEM_UNIT_MEASURE" ("ID_ITEM_UNIT_MEASURE") ENABLE,
CONSTRAINT "ITM_ISTAT_FK" FOREIGN KEY ("ID_ITEM_STATUS")
REFERENCES "TRAINNING"."ITEM_STATUS" ("ID_ITEM_STATUS") ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "TABLE_M" ;
As result I have for the entity constructor:
Expected (one of the machines have this)
Code:
@Entity
@Table(name="ITEM",schema="TRAINNING")
public class Item extends itemGeneric
{
private static final long serialVersionUID = 1L;
public Item(String code, PfwItemUnitMeasure pfwItemUnitMeasure, PfwItemCategory pfwItemCategory, PfwItemStatus pfwItemStatus)
{
super(code, pfwItemUnitMeasure, pfwItemCategory, pfwItemStatus);
}
Obtained (in other machine):
Code:
@Entity
@Table(name="ITEM",schema="TRAINNING")
public class Item extends itemGeneric
{
public Item(String code, PfwItemStatus pfwItemStatus, PfwItemCategory pfwItemCategory, PfwItemUnitMeasure pfwItemUnitMeasure)
{
super(code, pfwItemStatus, pfwItemCategory, pfwItemUnitMeasure);
}
My explanation is that the order is defined by the order of creation... but Why? How to change?
pfwItemStatus,
pfwItemCategory and
pfwItemUnitMeasure are FKs on the table.
pfwItemStatus and
pfwItemUnitMeasure appears swapped
Does anyone know why this happens or how to force the order?
Thanks
Miguel