Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.1
Mapping documents:
<?xml version="1.0"?>
<!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.TransComponent" table="POS_TRANS_COMPONENT"
dynamic-insert="false"
dynamic-update="false">
<id name="biTransactionId" type="string" column="BI_TRANSACTION_ID" >
<generator class="assigned"/>
</id>
<property name="externalId">
<column name="EXTERNAL_ID"/>
</property>
<property name="externalIdType" >
<column name="EXTERNAL_ID_TYPE"/>
</property>
<property name="activeDate">
<column name="ACTIVE_DATE"/>
</property>
<property name="componentId">
<column name="COMPONENT_ID"/>
</property>
<property name="componentInstanceId">
<column name="COMPONENT_INSTANCE_ID"/>
</property>
<property name="componentInstanceIdServ">
<column name="COMPONENT_INSTANCE_ID_SERV"/>
</property>
<property name="inActiveDate">
<column name="INACTIVE_DT"/>
</property>
<property name="productgroupId">
<column name="PRODUCT_GROUP_ID"/>
</property>
<property name="compTrackingId">
<column name="COMP_TRACKING_ID"/>
</property>
<property name="compTrackingIdServ">
<column name="COMP_TRACKING_ID_SERV"/>
</property>
<property name="packageInstanceId">
<column name="PACKAGE_INSTANCE_ID"/>
</property>
<property name="packageInstanceIdServ">
<column name="PACKAGE_INSTANCE_ID_SERV"/>
</property>
<property name="rate">
<column name="RATE"/>
</property>
<property name="serviceLocationNo">
<column name="SERVICE_LOCATION_NO"/>
</property>
</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:Oracle 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Class Code:
package com;
import java.sql.Date;
public class TransComponent {
private String biTransactionId= null;
private String externalId= null;
private int externalIdType;
private Date activeDate= null;
private long componentId;
private long componentInstanceId;
private long componentInstanceIdServ;
private String inActiveDate= null;
private long productgroupId;
private long compTrackingId;
private int compTrackingIdServ;
private long packageInstanceId;
private int packageInstanceIdServ;
private int rate;
private String serviceLocationNo= null;
public Date getActiveDate() {
return activeDate;
}
public void setActiveDate(Date activeDate) {
this.activeDate = activeDate;
}
public String getBiTransactionId() {
return biTransactionId;
}
public void setBiTransactionId(String biTransactionId) {
this.biTransactionId = biTransactionId;
}
public long getComponentId() {
return componentId;
}
public void setComponentId(long componentId) {
this.componentId = componentId;
}
public long getComponentInstanceId() {
return componentInstanceId;
}
public void setComponentInstanceId(long componentInstanceId) {
this.componentInstanceId = componentInstanceId;
}
public long getComponentInstanceIdServ() {
return componentInstanceIdServ;
}
public void setComponentInstanceIdServ(long componentInstanceIdServ) {
this.componentInstanceIdServ = componentInstanceIdServ;
}
public long getCompTrackingId() {
return compTrackingId;
}
public void setCompTrackingId(long compTrackingId) {
this.compTrackingId = compTrackingId;
}
public int getCompTrackingIdServ() {
return compTrackingIdServ;
}
public void setCompTrackingIdServ(int compTrackingIdServ) {
this.compTrackingIdServ = compTrackingIdServ;
}
public String getExternalId() {
return externalId;
}
public void setExternalId(String externalId) {
this.externalId = externalId;
}
public int getExternalIdType() {
return externalIdType;
}
public void setExternalIdType(int externalIdType) {
this.externalIdType = externalIdType;
}
public String getInActiveDate() {
return inActiveDate;
}
public void setInActiveDate(String inactiveDate) {
this.inActiveDate = inactiveDate;
}
public long getPackageInstanceId() {
return packageInstanceId;
}
public void setPackageInstanceId(long packageInstanceId) {
this.packageInstanceId = packageInstanceId;
}
public int getPackageInstanceIdServ() {
return packageInstanceIdServ;
}
public void setPackageInstanceIdServ(int packageInstanceIdServ) {
this.packageInstanceIdServ = packageInstanceIdServ;
}
public long getProductgroupId() {
return productgroupId;
}
public void setProductgroupId(long productgroupId) {
this.productgroupId = productgroupId;
}
public int getRate() {
return rate;
}
public void setRate(int rate) {
this.rate = rate;
}
public String getServiceLocationNo() {
return serviceLocationNo;
}
public void setServiceLocationNo(String serviceLocationNo) {
this.serviceLocationNo = serviceLocationNo;
}
}
In the above mentioned class, I have class level variables with type
int and
long and when I don't populate the those values before saving that object, the correspoding columns in the table have value
0.
Now how do I avoid inserting the java's default values in the database for example inserting 'null' or nothing in the
long fields in the above class.
Thanks in advance.
-Jam