Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.5
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="com.siemens.swa.domain.ActivityStateLog"
table="ACTIVITY_STATE_LOG"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
lazy="true"
batch-size="6"
>
<id
name="id"
column="ACT_STA_LOG_ID"
type="java.lang.Long"
>
<generator class="native"/>
</id>
<many-to-one
name="user"
class="com.siemens.swa.domain.User"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="USER_ID"
foreign-key="fk_activitystatelog_user"
/>
<property
name="date"
column="DATE"
/>
<property
name="state"
type="com.siemens.swa.dao.ActivityStateUserType"
update="true"
insert="true"
access="property"
column="STATE"
length="10"
/>
<property
name="substate"
type="com.siemens.swa.dao.ActivityExecutionStatusUserType"
update="true"
insert="true"
access="property"
column="SUBSTATE"
/>
</class>
</hibernate-mapping>
AND
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="com.siemens.swa.domain.ActivityExecution"
table="ACTIVITY_EXECUTION"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
lazy="true"
batch-size="6"
>
<id
name="id"
column="ACT_EXECUTION_ID"
type="java.lang.Long"
>
<generator class="native"/>
</id>
<property
name="date"
column="DATE"
/>
<property
name="time"
column="TIME"
/>
<many-to-one
name="technician"
class="com.siemens.swa.domain.Technician"
cascade="none"
outer-join="auto"
access="property"
foreign-key="fk_activityexecution_technician"
column="TECHNICIAN_ID"
unique="false"
/>
<many-to-one
name="dispatcher"
class="com.siemens.swa.domain.Dispatcher"
cascade="none"
outer-join="auto"
access="property"
column="DISPATCHER_ID"
unique="false"
foreign-key="fk_activityexecution_dispatcher"
/>
<property
name="status"
type="com.siemens.swa.dao.ActivityExecutionStatusUserType"
update="true"
insert="true"
access="property"
column="STATUS"
not-null="true"
/>
<set
name="stateLog"
lazy="true"
cascade="all"
order-by="DATE ASC"
sort="unsorted"
batch-size="6"
outer-join="auto"
>
<key
column="ACT_EXECUTION_ID"
>
</key>
<one-to-many
class="com.siemens.swa.domain.ActivityStateLog"
/>
</set>
<list name="tracks" lazy="true" batch-size="6" outer-join="auto" table="TRACK_EXECUTION_INFO" cascade="all">
<key column="ACT_EXECUTION_ID"/>
<index column="TRK_EXEC_ORDER"></index>
<composite-element class="com.siemens.swa.domain.TrackingExecutionInfo">
<parent name="activityExecution"/>
<many-to-one name="trackingExecution"
class="com.siemens.swa.domain.TrackingExecution"
cascade="all"
column="TRK_EXECUTION_ID"
not-null="false"
outer-join="auto"/>
<many-to-one name="executionClosing"
class="com.siemens.swa.domain.ExecutionClosing"
cascade="all"
column="EXEC_CLOSING_ID"
not-null="false"
outer-join="auto"/>
</composite-element>
</list>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
MySQL 4.1 without innodb
The generated SQL (show_sql=true):
alter table ACTIVITY_STATE_LOG drop foreign key fk_activitystatelog_user;
alter table ACTIVITY_STATE_LOG drop foreign key FKA7B11926170F6ACE;
...
alter table ACTIVITY_EXECUTION drop foreign key fk_activityexecution_dispatcher;
alter table ACTIVITY_EXECUTION drop foreign key fk_activityexecution_technician;
...
create table ACTIVITY_EXECUTION (ACT_EXECUTION_ID bigint not null auto_increment, DATE date, TIME time, TECHNICIAN_ID bigint, DISPATCHER_ID bigint, STATUS varchar(255) not null, primary key (ACT_EXECUTION_ID));
Debug level Hibernate log excerpt:
Hi all,
I've combed thru the archives and I can't seem to understand how to fix the problem in my case - the funky number that is being generated. My create.sql script is 600 lines so excuse if its too annotated - I'll post the whole thing if need be. I have 79 hbm files and lots of errors like these. We simply edit all the 'alter table' commands out, but we'd like to start using the foreign keys.
The common errors I seen here were incorrect column name and 'inverse' errors. However, I can't seem to see these errors here.
We want to use innodb, so we are interested in fixing this error.
Any ideas?
iksrazal