Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]Hibernate version:3.0[/b]
[b]Mapping documents:
-- Ticket Master Entity--
@Entity
@Table(name="Ticket_Master")
public class TicketMaster {
// @Id
// @GeneratedValue
// @Column(name="ID")
// private Long id;
@Id
@Column(name="TICKET_ID")
private String ticketID;
@Column(name="ASSGN_USER_ID")
private String assgnUserID;
@Column(name="ASSGN_GROUP_ID")
private Long assgnGroupID;
@Column(name="ASSGN_DEPT_ID")
private Long assgnDeptID;
@Column(name="BRANCH_ID")
private Long assgnBranchID;
@Column(name="TICKET_CREATED_BY")
private String ticketCreatedBy;
@Column(name="TICKET_STATUS_ID")
private Long ticketStatusID;
@Column(name="TICKET_PRIORITY_ID")
private Long ticketPriorityID;
@Column(name="TERM_TYPE_ID")
private Long termTypeID;
@Column(name="CREATED_BY")
private Long createdBy;
@Column(name="CREATE_DATE")
private Date createdDate;
@Column(name="LAST_UPDATE_BY")
private Long lastUpdateBy;
@Column(name="LAST_UPDATE_DATE")
private Date lastUpdateDate;
@OneToOne(mappedBy="ticketMaster")
@PrimaryKeyJoinColumn
private AirRegister airRegister;
public AirRegister getAirRegister() {
return airRegister;
}
public void setAirRegister(AirRegister airRegister) {
this.airRegister = airRegister;
}
@OneToOne(mappedBy="ticketMaster")
@PrimaryKeyJoinColumn
private SeaRegister seaRegister;
public SeaRegister getSeaRegister() {
return seaRegister;
}
public void setSeaRegister(SeaRegister seaRegister) {
this.seaRegister = seaRegister;
}
-- TicketMaster Entity --
-- AirRegister Entity --
@Id
@GeneratedValue
@Column(name="ID")
private Long id;
@OneToOne
@JoinColumn(name="TICKET_AIR_REG_ID")
private TicketMaster ticketMaster;
@Column(name="DEPT_AIRPORT")
private String deptAirport;
@Column(name="DEST_AIRPORT")
private String destAirport;
@Column(name="AIRLINE_TYPE")
private String airlineType;
@Column(name="FLIGHT_NR")
private String flightNR;
@Column(name="GOODS_WEIGHT")
private String goodsWeight;
@Column(name="CREATED_BY")
private Long createdBy;
@Column(name="CREATE_DATE")
private Date createdDate;
@Column(name="LAST_UPDATE_BY")
private Long lastUpdateBy;
@Column(name="LAST_UPDATE_DATE")
private Date lastUpdateDate;
-- AirRegister Entity
[/b]
[b]
Session session = sessionFactory.openSession();
System.out.println(session);
Transaction tx = session.getTransaction();
System.out.println("Tx get");
try {
System.out.println("Tx before begin");
tx.begin();
System.out.println("Tx After begin");
session.saveOrUpdate(ticketMaster);
tx.commit();
} catch (RuntimeException e) {
tx.rollback();
throw e;
} finally {
session.close();
}
b]
[b]No exception is coming; record inserted into master table; child tables not inserting[/b]
[b]Name and version of the database you are using:[/b]
[b]The generated SQL (show_sql=true):[/b]
[b]Debug level Hibernate log excerpt:[/b]
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html