These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: many-to-one formula order problem
PostPosted: Tue May 15, 2007 6:16 am 
Newbie

Joined: Fri Dec 01, 2006 10:01 am
Posts: 6
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;
    }
   
...
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.