Hi,
I noticed the next problem while deploying my application on multiple machines :
I have a many-to-one association between one class (irrelevant)
and my object of type ApplicationType.
The object of type ApplicationType has an embeddable id.
When referring to that table in my mapping file, i use 3 formula sections.
When running the application, behind the scenes hibernate does an incorrect mapping of the formula's :
It generates an ApplicationType object, but it mistakenly swaps two of the three String fields that comprise the object's id.
Is there a way to specify to Hibernate which formula corresponds to which field ? I see the inherent problem of having 3 Strings comprising the id,
but if i could tell hibernate the relation between them ...
This error occurs on my Windows machine , but not on my Solaris box.
So it could happend randomly, because it looks to me Hibernate currently has no way of knowing the right mapping, it can only guess ...
Or do i need to use a different approach to solve the problem ?
I've tried with different versions of hibernate, the most recent one last (3.3.2 GA)
My relevant mappings/annotations :
Code:
...
<many-to-one name="atype" class="acme.ApplicationType" update="false" insert="false">
<formula>SUBSTR(APPLMODID, 1, 2)</formula>
<formula>'ATYPE'</formula>
<formula>'0'</formula>
</many-to-one>
...
AND the relevant ApplicationType object is an annotated one:
Code:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue ( "ATYPE" )
public class ApplicationType extends Parameter implements Serializable{
private Set<ModuleType> moduleTypes = new HashSet<ModuleType>(0);
private static final long serialVersionUID = 2482767249388975498L;
@OneToMany
public Set<ModuleType> getModuleTypes() {
return moduleTypes;
}
public void setModuleTypes(Set<ModuleType> moduleTypes) {
this.moduleTypes = moduleTypes;
}
}
with it's parent :
Code:
@Entity
@Table (name = "PARAMETER", schema = "COMS_DATA")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn ( name = "TYPE", discriminatorType = DiscriminatorType.STRING )
@IdClass(ParameterId.class)
public class Parameter implements Serializable {
protected String id = null;
protected String type = null;
protected String parentId = null;
@Id
@Column(name = "TYPE", unique = false, nullable = false, insertable = false, updatable = false)
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Id
@Column(name = "ID", unique = false, nullable = false, insertable = false, updatable = false)
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Id
@Column(name = "PARENT_ID", unique = false, nullable = true, insertable = false, updatable = false)
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
...
}