-->
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: SecondaryTable with only foreign keys not being inserted.
PostPosted: Thu Jan 12, 2012 6:29 pm 
Newbie

Joined: Thu Jan 12, 2012 6:18 pm
Posts: 1
I have the following classes defined in my system. When I attempt to persist them, the minValue and maxValue are not being persisted. and the minMaxRule table is not persisted either, the base table for the inheritance chain "Rule" does get updated with the appropriate info. I've run into this issue in a slightly different way before where a secondary table with all null values does not get generated, and it looks like even though there are comparevalues for min and max, since the id's are null to start hibernate thinks the secondaryTable will be null as well.

Any ideas?

Thanks
Robert Brown

Code:
@Entity
@SecondaryTable(name = "MinMaxRule", pkJoinColumns = @PrimaryKeyJoinColumn(name = "id", referencedColumnName = "id"))
@org.hibernate.annotations.Table(appliesTo="minmaxRule", optional=false)
@DiscriminatorValue("MIN_MAX")
public class MinMaxRule extends FieldRule {

    private Comparevalue minValue;
    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(table = "MinMaxRule", name = "CompareMinimumValue_id", referencedColumnName = "id")
    public Comparevalue getMinValue() {
        return minValue;
    }

    public void setMinValue(Comparevalue minValue) {
        this.minValue = minValue;
    }

    private Comparevalue maxValue;
    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(table = "MinMaxRule", name = "CompareMaximumValue_id", referencedColumnName = "id")
    public Comparevalue getMaxValue() {
        return maxValue;
    }

    public void setMaxValue(Comparevalue maxValue) {
        this.maxValue = maxValue;
    }

}


@Entity
//@Audited
public class Comparevalue {
    private Integer id;

    @javax.persistence.Column(name = "id")
    @Id
    @GeneratedValue()
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    private String value;

    @javax.persistence.Column(name = "value")
    @Basic
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    private Boolean constant;

    @javax.persistence.Column(name = "static")
    @Basic
    public Boolean getConstant() {
        return constant;
    }

    public void setConstant(Boolean constant) {
        this.constant = constant;
    }
}


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.