Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html
I am looking for many-to-many mapping of this schema, but instead it was mapped as two one-to-many:
SCHEMA:
create table else_control(
from_case_control_id number(*,0) not null,
to_case_control_id number(*,0) not null,
statement_order varchar2(50) not null
);
alter table else_control add constraint else_control_id primary key (from_case_control_id,to_case_control_id);
create table case_control(
case_control_id number(*,0) not null
);
alter table case_control add constraint case_control_id primary key (case_control_id);
alter table else_control add constraint else_control_from foreign key (from_case_control_id) references case_control (case_control_id);
alter table else_control add constraint else_control_to foreign key (to_case_control_id) references case_control (case_control_id);
IN THE CaseControl POJO I see:
public class CaseControl implements java.io.Serializable {
private Integer caseControlId;
private Set<ElseControl> elseControlsForFromCaseControlId = new HashSet<ElseControl>(
0);
private Set<ElseControl> elseControlsForToCaseControlId = new HashSet<ElseControl>(
0);
public CaseControl() {
}
public CaseControl(Set<ElseControl> elseControlsForFromCaseControlId,
Set<ElseControl> elseControlsForToCaseControlId) {
this.elseControlsForFromCaseControlId = elseControlsForFromCaseControlId;
this.elseControlsForToCaseControlId = elseControlsForToCaseControlId;
}
@Id
@GeneratedValue
@Column(name = "CASE_CONTROL_ID", unique = true, nullable = false, precision = 22, scale = 0)
public Integer getCaseControlId() {
return this.caseControlId;
}
public void setCaseControlId(Integer caseControlId) {
this.caseControlId = caseControlId;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "caseControlByFromCaseControlId")
public Set<ElseControl> getElseControlsForFromCaseControlId() {
return this.elseControlsForFromCaseControlId;
}
public void setElseControlsForFromCaseControlId(
Set<ElseControl> elseControlsForFromCaseControlId) {
this.elseControlsForFromCaseControlId = elseControlsForFromCaseControlId;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "caseControlByToCaseControlId")
public Set<ElseControl> getElseControlsForToCaseControlId() {
return this.elseControlsForToCaseControlId;
}
public void setElseControlsForToCaseControlId(
Set<ElseControl> elseControlsForToCaseControlId) {
this.elseControlsForToCaseControlId = elseControlsForToCaseControlId;
}
}
IN XML for CaseControl:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 18, 2008 2:44:49 PM by Hibernate Tools 3.2.0.CR1 -->
<hibernate-mapping>
<class name="dbMapping.CaseControl" table="CASE_CONTROL" schema="NATALIA">
<id name="caseControlId" type="integer">
<column name="CASE_CONTROL_ID" precision="22" scale="0" />
<generator class="native" />
</id>
<set name="elseControlsForFromCaseControlId" inverse="true">
<key>
<column name="FROM_CASE_CONTROL_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="dbMapping.ElseControl" />
</set>
<set name="elseControlsForToCaseControlId" inverse="true">
<key>
<column name="TO_CASE_CONTROL_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="dbMapping.ElseControl" />
</set>
</class>
</hibernate-mapping>
THANK YOU IN ADVANCE!!!!!