Hibernate version:
Hibernate 3.0 using Hibernate/Spring for a standalone app.
Mapping documents:
Below is the "parent":
Code:
<?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="InterfaceFileSchema"
table="INTERFACE_FILE_SCHEMA"
>
<meta attribute="implement-equals" inherit="false">true</meta>
<composite-id name="comp_id" class="InterfaceFileSchemaPK">
<key-property
name="interfaceName"
column="INTERFACE_NAME"
type="java.lang.String"
length="50"
/>
<key-property
name="executionClass"
column="EXECUTION_CLASS"
type="java.lang.String"
length="255"
/>
<key-property
name="schemaName"
column="SCHEMA_NAME"
type="java.lang.String"
length="50"
/>
</composite-id>
<property
name="schemaType"
type="java.lang.Integer"
column="SCHEMA_TYPE"
not-null="true"
length="10"
/>
<property
name="fileLocation"
type="java.lang.String"
column="FILE_LOCATION"
not-null="true"
length="50"
/>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- bi-directional many-to-one association to Iface -->
<many-to-one
name="iface"
class="Iface"
update="false"
insert="false"
not-found="ignore"
>
<column name="INTERFACE_NAME" />
<column name="EXECUTION_CLASS" />
</many-to-one>
<!-- end of derived association(s) -->
<!-- bi-directional one-to-many association to InterfaceRunLog -->
<set
name="interfaceRunLogs"
lazy="true"
inverse="true"
cascade="none"
>
<key>
<column name="INTERFACE_NAME" />
<column name="EXECUTION_CLASS" />
<column name="SCHEMA_NAME" />
</key>
<one-to-many
class="InterfaceRunLog"
/>
</set>
<!-- bi-directional one-to-many association to InterfaceErrorLog -->
<set
name="interfaceErrorLogs"
lazy="true"
inverse="true"
cascade="none"
>
<key>
<column name="INTERFACE_NAME" />
<column name="EXECUTION_CLASS" />
<column name="SCHEMA_NAME" />
</key>
<one-to-many
class="InterfaceErrorLog" not-found="ignore"
/>
</set>
</class>
</hibernate-mapping>
This is the "child":
Code:
<?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="InterfaceRunLog"
table="INTERFACE_RUN_LOG"
>
<meta attribute="implement-equals" inherit="false">true</meta>
<composite-id name="comp_id" class="InterfaceRunLogPK">
<key-property
name="schemaName"
column="SCHEMA_NAME"
type="java.lang.String"
length="50"
/>
<key-property
name="timeStarted"
column="TIME_STARTED"
type="java.sql.Date"
length="-1"
/>
<key-property
name="interfaceName"
column="INTERFACE_NAME"
type="java.lang.String"
length="50"
/>
<key-property
name="executionClass"
column="EXECUTION_CLASS"
type="java.lang.String"
length="255"
/>
</composite-id>
<property
name="timeEnded"
type="java.sql.Date"
column="TIME_ENDED"
not-null="true"
length="-1"
/>
<property
name="rowsProcessed"
type="java.lang.Long"
column="ROWS_PROCESSED"
not-null="true"
length="19"
/>
<property
name="rowsWithErrors"
type="java.lang.Long"
column="ROWS_WITH_ERRORS"
not-null="true"
length="19"
/>
<many-to-one
name="interfaceFileSchema"
class="InterfaceFileSchema"
update="false"
insert="false"
not-found="ignore"
>
<column name="INTERFACE_NAME" />
<column name="EXECUTION_CLASS" />
<column name="SCHEMA_NAME" />
</many-to-one>
<!-- end of derived association(s) -->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():N/A
Full stack trace of any exception that occurs:Code:
Exception in thread "main" org.hibernate.PropertyAccessException: exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of InterfaceRowSchemaPK.?
at org.hibernate.tuple.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:42)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:257)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:158)
at org.hibernate.engine.EntityKey.getHashCode(EntityKey.java:68)
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:41)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:69)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:655)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:261)
at org.hibernate.type.EntityType.resolve(EntityType.java:286)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
at org.hibernate.loader.Loader.doQuery(Loader.java:436)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1434)
at org.hibernate.loader.collection.OneToManyLoader.initialize(OneToManyLoader.java:111)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1430)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:176)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:48)
at org.hibernate.collection.PersistentSet.toString(PersistentSet.java:222)
at java.lang.String.valueOf(String.java(Inlined Compiled Code))
at java.lang.StringBuffer.append(StringBuffer.java(Compiled Code))
at TestSpringHibernateRunner.retrieveInterface(TestSpringHibernateRunner.java:106)
at TestSpringHibernateRunner.main(TestSpringHibernateRunner.java:44)
Caused by: java.lang.ClassCastException: InterfaceFileSchemaPK
at InterfaceRowSchemaPK$$BulkBeanByCGLIB$$88320853.getPropertyValues(<generated>)
at net.sf.cglib.beans.BulkBean.getPropertyValues(BulkBean.java:48)
at org.hibernate.tuple.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:39)
... 24 more
Name and version of the database you are using:Cloudscape 5.1
The generated SQL (show_sql=true):N/A
Debug level Hibernate log excerpt:Code:
Hibernate: select interfacef0_.INTERFACE_NAME as INTERFACE1_1_, interfacef0_.EXECUTION_CLASS as EXECUTION2_1_, interfacef0_.SCHEMA_NAME as SCHEMA3_1_, interfacef0_.INTERFACE_NAME as INTERFACE1_0_, interfacef0_.EXECUTION_CLASS as EXECUTION2_0_, interfacef0_.SCHEMA_NAME as SCHEMA3_0_, interfacef0_.SCHEMA_TYPE as SCHEMA4_5_0_, interfacef0_.FILE_LOCATION as FILE5_5_0_, interfacef0_.INTERFACE_NAME as INTERFACE1_5_0_, interfacef0_.EXECUTION_CLASS as EXECUTION2_5_0_ from VOIS_TEST.INTERFACE_FILE_SCHEMA interfacef0_ where interfacef0_.INTERFACE_NAME=? and interfacef0_.EXECUTION_CLASS=?
08/15 14:25:52,409 DEBUG main (AbstractBatcher:378) - preparing statement
08/15 14:25:52,581 DEBUG main (StringType:59) - binding 'testCommaDelimToFixedLen' to parameter: 1
08/15 14:25:52,581 DEBUG main (StringType:59) - binding 'ModifyCommaDelimFile' to parameter: 2
08/15 14:25:52,597 DEBUG main (AbstractBatcher:306) - about to open ResultSet (open ResultSets: 0, globally: 0)
08/15 14:25:52,597 DEBUG main (Loader:718) - result set contains (possibly empty) collection: [Iface.interfaceFileSchemas#component[interfaceName,executionClass]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen}]
08/15 14:25:52,597 DEBUG main (CollectionLoadContext:85) - uninitialized collection: initializing
08/15 14:25:52,597 DEBUG main (Loader:405) - processing result set
08/15 14:25:52,597 DEBUG main (Loader:410) - result set row: 0
08/15 14:25:52,597 DEBUG main (StringType:86) - returning 'testCommaDelimToFixedLen' as column: INTERFACE1_0_
08/15 14:25:52,597 DEBUG main (StringType:86) - returning 'ModifyCommaDelimFile' as column: EXECUTION2_0_
08/15 14:25:52,597 DEBUG main (StringType:86) - returning 'commaDelim' as column: SCHEMA3_0_
08/15 14:25:52,597 DEBUG main (Loader:828) - result row: EntityKey[InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=commaDelim}]
08/15 14:25:52,597 DEBUG main (Loader:978) - Initializing object from ResultSet: [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=commaDelim}]
08/15 14:25:52,597 DEBUG main (BasicEntityPersister:1651) - Hydrating entity: [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=commaDelim}]
08/15 14:25:52,597 DEBUG main (IntegerType:86) - returning '1' as column: SCHEMA4_5_0_
08/15 14:25:52,597 DEBUG main (StringType:86) - returning 'c:\output\comma-1.txt' as column: FILE5_5_0_
08/15 14:25:52,597 DEBUG main (StringType:86) - returning 'testCommaDelimToFixedLen' as column: INTERFACE1_5_0_
08/15 14:25:52,597 DEBUG main (StringType:86) - returning 'ModifyCommaDelimFile' as column: EXECUTION2_5_0_
08/15 14:25:52,612 DEBUG main (StringType:86) - returning 'testCommaDelimToFixedLen' as column: INTERFACE1_1_
08/15 14:25:52,612 DEBUG main (StringType:86) - returning 'ModifyCommaDelimFile' as column: EXECUTION2_1_
08/15 14:25:52,612 DEBUG main (Loader:654) - found row of collection: [Iface.interfaceFileSchemas#component[interfaceName,executionClass]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen}]
08/15 14:25:52,612 DEBUG main (CollectionLoadContext:112) - reading row
08/15 14:25:52,612 DEBUG main (StringType:86) - returning 'testCommaDelimToFixedLen' as column: INTERFACE1_1_
08/15 14:25:52,612 DEBUG main (StringType:86) - returning 'ModifyCommaDelimFile' as column: EXECUTION2_1_
08/15 14:25:52,612 DEBUG main (StringType:86) - returning 'commaDelim' as column: SCHEMA3_1_
08/15 14:25:52,612 DEBUG main (DefaultLoadEventListener:143) - loading entity: [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=commaDelim}]
08/15 14:25:52,612 DEBUG main (DefaultLoadEventListener:290) - attempting to resolve: [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=commaDelim}]
08/15 14:25:52,612 DEBUG main (DefaultLoadEventListener:299) - resolved object in session cache: [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=commaDelim}]
08/15 14:25:52,612 DEBUG main (Loader:410) - result set row: 1
08/15 14:25:52,612 DEBUG main (StringType:86) - returning 'testCommaDelimToFixedLen' as column: INTERFACE1_0_
08/15 14:25:52,612 DEBUG main (StringType:86) - returning 'ModifyCommaDelimFile' as column: EXECUTION2_0_
08/15 14:25:52,612 DEBUG main (StringType:86) - returning 'fixedLen' as column: SCHEMA3_0_
08/15 14:25:52,612 DEBUG main (Loader:828) - result row: EntityKey[InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=fixedLen}]
08/15 14:25:52,612 DEBUG main (Loader:978) - Initializing object from ResultSet: [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=fixedLen}]
08/15 14:25:52,612 DEBUG main (BasicEntityPersister:1651) - Hydrating entity: [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=fixedLen}]
08/15 14:25:52,628 DEBUG main (IntegerType:86) - returning '0' as column: SCHEMA4_5_0_
08/15 14:25:52,628 DEBUG main (StringType:86) - returning 'c:\output\fixed-comma-1.txt' as column: FILE5_5_0_
08/15 14:25:52,628 DEBUG main (StringType:86) - returning 'testCommaDelimToFixedLen' as column: INTERFACE1_5_0_
08/15 14:25:52,628 DEBUG main (StringType:86) - returning 'ModifyCommaDelimFile' as column: EXECUTION2_5_0_
08/15 14:25:52,628 DEBUG main (StringType:86) - returning 'testCommaDelimToFixedLen' as column: INTERFACE1_1_
08/15 14:25:52,628 DEBUG main (StringType:86) - returning 'ModifyCommaDelimFile' as column: EXECUTION2_1_
08/15 14:25:52,628 DEBUG main (Loader:654) - found row of collection: [Iface.interfaceFileSchemas#component[interfaceName,executionClass]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen}]
08/15 14:25:52,628 DEBUG main (CollectionLoadContext:112) - reading row
08/15 14:25:52,628 DEBUG main (StringType:86) - returning 'testCommaDelimToFixedLen' as column: INTERFACE1_1_
08/15 14:25:52,628 DEBUG main (StringType:86) - returning 'ModifyCommaDelimFile' as column: EXECUTION2_1_
08/15 14:25:52,628 DEBUG main (StringType:86) - returning 'fixedLen' as column: SCHEMA3_1_
08/15 14:25:52,628 DEBUG main (DefaultLoadEventListener:143) - loading entity: [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=fixedLen}]
08/15 14:25:52,628 DEBUG main (DefaultLoadEventListener:290) - attempting to resolve: [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=fixedLen}]
08/15 14:25:52,628 DEBUG main (DefaultLoadEventListener:299) - resolved object in session cache: [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=fixedLen}]
08/15 14:25:52,628 DEBUG main (Loader:429) - done processing result set (2 rows)
08/15 14:25:52,628 DEBUG main (AbstractBatcher:313) - about to close ResultSet (open ResultSets: 1, globally: 1)
08/15 14:25:52,628 DEBUG main (AbstractBatcher:298) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
08/15 14:25:52,628 DEBUG main (AbstractBatcher:416) - closing statement
08/15 14:25:52,628 DEBUG main (Loader:528) - total objects hydrated: 2
08/15 14:25:52,628 DEBUG main (TwoPhaseLoad:96) - resolving associations for [InterfaceFileSchema#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=commaDelim}]
08/15 14:25:52,628 DEBUG main (DefaultLoadEventListener:143) - loading entity: [Iface#component[interfaceName,executionClass]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen}]
08/15 14:25:52,643 DEBUG main (DefaultLoadEventListener:186) - entity proxy found in session cache
08/15 14:25:52,643 DEBUG main (CollectionLoadContext:141) - creating collection wrapper:[InterfaceFileSchema.interfaceRunLogs#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=commaDelim}]
08/15 14:25:52,643 DEBUG main (CollectionLoadContext:141) - creating collection wrapper:[InterfaceFileSchema.interfaceErrorLogs#component[interfaceName,executionClass,schemaName]{executionClass=ModifyCommaDelimFile, interfaceName=testCommaDelimToFixedLen, schemaName=commaDelim}]
POJOs"Parent POJO":
Code:
import java.io.Serializable;
import java.util.Set;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class InterfaceFileSchema implements Serializable {
/** identifier field */
private InterfaceFileSchemaPK comp_id;
/** persistent field */
private Integer schemaType;
/** persistent field */
private String fileLocation;
/** nullable persistent field */
private InterfaceRowSchema interfaceRowSchema;
/** nullable persistent field */
private Iface iface;
/** persistent field */
private Set interfaceRunLogs;
/** persistent field */
private Set interfaceErrorLogs;
/** persistent field */
private Set interfaceErrorThresholds;
/** full constructor */
public InterfaceFileSchema(InterfaceFileSchemaPK comp_id, Integer schemaType, String fileLocation, InterfaceRowSchema interfaceRowSchema, Iface iface, Set interfaceRunLogs, Set interfaceErrorLogs, Set interfaceErrorThresholds) {
this.comp_id = comp_id;
this.schemaType = schemaType;
this.fileLocation = fileLocation;
this.interfaceRowSchema = interfaceRowSchema;
this.iface = iface;
this.interfaceRunLogs = interfaceRunLogs;
this.interfaceErrorLogs = interfaceErrorLogs;
this.interfaceErrorThresholds = interfaceErrorThresholds;
}
/** default constructor */
public InterfaceFileSchema() {
}
/** minimal constructor */
public InterfaceFileSchema(InterfaceFileSchemaPK comp_id, Integer schemaType, String fileLocation, Set interfaceRunLogs, Set interfaceErrorLogs, Set interfaceErrorThresholds) {
this.comp_id = comp_id;
this.schemaType = schemaType;
this.fileLocation = fileLocation;
this.interfaceRunLogs = interfaceRunLogs;
this.interfaceErrorLogs = interfaceErrorLogs;
this.interfaceErrorThresholds = interfaceErrorThresholds;
}
public InterfaceFileSchemaPK getComp_id() {
return this.comp_id;
}
public void setComp_id(InterfaceFileSchemaPK comp_id) {
this.comp_id = comp_id;
}
public Integer getSchemaType() {
return this.schemaType;
}
public void setSchemaType(Integer schemaType) {
this.schemaType = schemaType;
}
public String getFileLocation() {
return this.fileLocation;
}
public void setFileLocation(String fileLocation) {
this.fileLocation = fileLocation;
}
InterfaceRowSchema getInterfaceRowSchema() {
return this.interfaceRowSchema;
}
public void setInterfaceRowSchema(InterfaceRowSchema interfaceRowSchema) {
this.interfaceRowSchema = interfaceRowSchema;
}
public Iface getIface() {
return this.iface;
}
public void setIface(Iface iface) {
this.iface = iface;
}
public Set getInterfaceRunLogs() {
return this.interfaceRunLogs;
}
public void setInterfaceRunLogs(Set interfaceRunLogs) {
this.interfaceRunLogs = interfaceRunLogs;
}
public Set getInterfaceErrorLogs() {
return this.interfaceErrorLogs;
}
public void setInterfaceErrorLogs(Set interfaceErrorLogs) {
this.interfaceErrorLogs = interfaceErrorLogs;
}
public Set getInterfaceErrorThresholds() {
return this.interfaceErrorThresholds;
}
public void setInterfaceErrorThresholds(Set interfaceErrorThresholds) {
this.interfaceErrorThresholds = interfaceErrorThresholds;
}
public String toString() {
return new ToStringBuilder(this)
.append("comp_id", getComp_id())
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof InterfaceFileSchema) ) return false;
InterfaceFileSchema castOther = (InterfaceFileSchema) other;
return new EqualsBuilder()
.append(this.getComp_id(), castOther.getComp_id())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getComp_id())
.toHashCode();
}
}
Parent Primary Key POJO
Code:
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class InterfaceFileSchemaPK implements Serializable {
/** identifier field */
private String interfaceName;
/** identifier field */
private String executionClass;
/** identifier field */
private String schemaName;
/** full constructor */
public InterfaceFileSchemaPK(String interfaceName, String executionClass, String schemaName) {
this.interfaceName = interfaceName;
this.executionClass = executionClass;
this.schemaName = schemaName;
}
/** default constructor */
public InterfaceFileSchemaPK() {
}
public String getInterfaceName() {
return this.interfaceName;
}
public void setInterfaceName(String interfaceName) {
this.interfaceName = interfaceName;
}
public String getExecutionClass() {
return this.executionClass;
}
public void setExecutionClass(String executionClass) {
this.executionClass = executionClass;
}
public String getSchemaName() {
return this.schemaName;
}
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
public String toString() {
return new ToStringBuilder(this)
.append("interfaceName", getInterfaceName())
.append("executionClass", getExecutionClass())
.append("schemaName", getSchemaName())
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof InterfaceFileSchemaPK) ) return false;
InterfaceFileSchemaPK castOther = (InterfaceFileSchemaPK) other;
return new EqualsBuilder()
.append(this.getInterfaceName(), castOther.getInterfaceName())
.append(this.getExecutionClass(), castOther.getExecutionClass())
.append(this.getSchemaName(), castOther.getSchemaName())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getInterfaceName())
.append(getExecutionClass())
.append(getSchemaName())
.toHashCode();
}
}
"Child" POJO:
Code:
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class InterfaceRunLog implements Serializable {
/** identifier field */
private InterfaceRunLogPK comp_id;
/** persistent field */
private Date timeEnded;
/** persistent field */
private Long rowsProcessed;
/** persistent field */
private Long rowsWithErrors;
/** nullable persistent field */
private InterfaceFileSchema interfaceFileSchema;
/** full constructor */
public InterfaceRunLog(InterfaceRunLogPK comp_id, Date timeEnded, Long rowsProcessed, Long rowsWithErrors, InterfaceFileSchema interfaceFileSchema) {
this.comp_id = comp_id;
this.timeEnded = timeEnded;
this.rowsProcessed = rowsProcessed;
this.rowsWithErrors = rowsWithErrors;
this.interfaceFileSchema = interfaceFileSchema;
}
/** default constructor */
public InterfaceRunLog() {
}
/** minimal constructor */
public InterfaceRunLog(InterfaceRunLogPK comp_id, Date timeEnded, Long rowsProcessed, Long rowsWithErrors) {
this.comp_id = comp_id;
this.timeEnded = timeEnded;
this.rowsProcessed = rowsProcessed;
this.rowsWithErrors = rowsWithErrors;
}
public InterfaceRunLogPK getComp_id() {
return this.comp_id;
}
public void setComp_id(InterfaceRunLogPK comp_id) {
this.comp_id = comp_id;
}
public Date getTimeEnded() {
return this.timeEnded;
}
public void setTimeEnded(Date timeEnded) {
this.timeEnded = timeEnded;
}
public Long getRowsProcessed() {
return this.rowsProcessed;
}
public void setRowsProcessed(Long rowsProcessed) {
this.rowsProcessed = rowsProcessed;
}
public Long getRowsWithErrors() {
return this.rowsWithErrors;
}
public void setRowsWithErrors(Long rowsWithErrors) {
this.rowsWithErrors = rowsWithErrors;
}
public InterfaceFileSchema getInterfaceFileSchema() {
return this.interfaceFileSchema;
}
public void setInterfaceFileSchema(InterfaceFileSchema interfaceFileSchema) {
this.interfaceFileSchema = interfaceFileSchema;
}
public String toString() {
return new ToStringBuilder(this)
.append("comp_id", getComp_id())
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof InterfaceRunLog) ) return false;
InterfaceRunLog castOther = (InterfaceRunLog) other;
return new EqualsBuilder()
.append(this.getComp_id(), castOther.getComp_id())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getComp_id())
.toHashCode();
}
}
"Child" Primary Key POJO:
Code:
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class InterfaceRunLogPK implements Serializable {
/** identifier field */
private String schemaName;
/** identifier field */
private Date timeStarted;
/** identifier field */
private String interfaceName;
/** identifier field */
private String executionClass;
/** full constructor */
public InterfaceRunLogPK(String schemaName, Date timeStarted, String interfaceName, String executionClass) {
this.schemaName = schemaName;
this.timeStarted = timeStarted;
this.interfaceName = interfaceName;
this.executionClass = executionClass;
}
/** default constructor */
public InterfaceRunLogPK() {
}
public String getSchemaName() {
return this.schemaName;
}
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
public Date getTimeStarted() {
return this.timeStarted;
}
public void setTimeStarted(Date timeStarted) {
this.timeStarted = timeStarted;
}
public String getInterfaceName() {
return this.interfaceName;
}
public void setInterfaceName(String interfaceName) {
this.interfaceName = interfaceName;
}
public String getExecutionClass() {
return this.executionClass;
}
public void setExecutionClass(String executionClass) {
this.executionClass = executionClass;
}
public String toString() {
return new ToStringBuilder(this)
.append("schemaName", getSchemaName())
.append("timeStarted", getTimeStarted())
.append("interfaceName", getInterfaceName())
.append("executionClass", getExecutionClass())
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof InterfaceRunLogPK) ) return false;
InterfaceRunLogPK castOther = (InterfaceRunLogPK) other;
return new EqualsBuilder()
.append(this.getSchemaName(), castOther.getSchemaName())
.append(this.getTimeStarted(), castOther.getTimeStarted())
.append(this.getInterfaceName(), castOther.getInterfaceName())
.append(this.getExecutionClass(), castOther.getExecutionClass())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getSchemaName())
.append(getTimeStarted())
.append(getInterfaceName())
.append(getExecutionClass())
.toHashCode();
}
}
NOTES* I know the database structure is odd, they will not use numeric generated keys here.
* The error happens when a table is empty. If the table has data, everything works fine.
QUESTIONS:Please let me know how I could set it up where there wouldn't be a failure when the parent tries to load it's children if the children have no data. Due to data archiving, it's quite possible these tables will have no data on occasion.
Thank you in advance for any advice you may provide. I am pretty new to Hibernate, so please be gentle.[/code]