-->
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: sequence generators are getting ignored
PostPosted: Thu Jun 03, 2010 4:55 pm 
Newbie

Joined: Tue Mar 21, 2006 7:16 pm
Posts: 3
I'm getting the following error while saving a object. However similar configuration is working for other model objects in my projects. Any help would be greatly appreciated.



Code:
@Entity
@Table(name = "ENROLLMENT_GROUP_MEMBERSHIPS", schema = "LEAD_ROUTING")
public class EnrollmentGroupMembership implements Serializable, Comparable,Auditable {
    @javax.persistence.SequenceGenerator(name = "enrollmentGroupMemID", sequenceName = "S_ENROLLMENT_GROUP_MEMBERSHIPS")
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "enrollmentGroupMemID")
    @Column(name = "ID")
    private Long id;


@ManyToOne()
    @JoinColumn(name = "TIER_WEIGHT_OID", referencedColumnName = "OID", updatable = false, insertable = false)
    private TierWeight tierWeight;

    public EnrollmentGroupMembership() {

    }

}

Code:
@Entity
@Table(name = "TIER_WEIGHT", schema = "LEAD_ROUTING")
public class TierWeight implements Serializable, Auditable {

@SequenceGenerator(name = "tierSequence",sequenceName = "S_TIER_WEIGHT")
    @Column(name = "OID")
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "tierSequence")
    private Long id;

@OneToMany
    @JoinColumn(name = "TIER_WEIGHT_OID", referencedColumnName = "OID")
    private Set<EnrollmentGroupMembership> memberships;


    public TierWeight() {
    }
}

The logic layer's code is

Code:
@Override
    public void createTier(String tierName, float weight) {
        TierWeight tier = new TierWeight();
        tier.setWeight(weight);
        tier.setTier(tierName);
        tierWeightDAO.create(tier);
    }

Similar Many-one configuration is working through out the project. I don't know why this one instance is failing. Any help would be greatly appreciated.

The following is the error that I'm getting

Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): edu.apollogrp.d2ec.model.TierWeight
at org.hibernate.id.Assigned.generate(Assigned.java:3 3)
at org.hibernate.event.def.AbstractSaveEventListener. saveWithGeneratedId(AbstractSaveEventListener.java :99)


The log file is telling that the sequence generator tierSequence is not getting created. However other sequence generators are getting created.

2010-06-03 11:24:51,834 DEBUG [org.hibernate.cfg.AnnotationBinder:] Processing annotations of edu.apollogrp.d2ec.model.TierWeight.dateCreated
2010-06-03 11:24:51,834 DEBUG [org.hibernate.cfg.AnnotationBinder:] Processing annotations of edu.apollogrp.d2ec.model.TierWeight.dateCreated
2010-06-03 11:24:51,834 DEBUG [org.hibernate.cfg.Ejb3Column:] Binding column DATE_CREATED unique false

.......................................
.......................................
2010-06-03 11:24:51,756 DEBUG [org.hibernate.cfg.AnnotationBinder:] Processing annotations of edu.apollogrp.d2ec.model.CounselorAvailability.id
2010-06-03 11:24:51,756 DEBUG [org.hibernate.cfg.Ejb3Column:] Binding column OID unique false
2010-06-03 11:24:51,756 DEBUG [org.hibernate.cfg.Ejb3Column:] Binding column OID unique false
2010-06-03 11:24:51,756 DEBUG [org.hibernate.cfg.AnnotationBinder:] id is an id
2010-06-03 11:24:51,756 DEBUG [org.hibernate.cfg.AnnotationBinder:] id is an id
2010-06-03 11:24:51,756 DEBUG [org.hibernate.cfg.AnnotationBinder:] Add sequence generator with name: counselorAvailabilityID
2010-06-03 11:24:51,756 DEBUG [org.hibernate.cfg.AnnotationBinder:] Add sequence generator with name: counselorAvailabilityID

---------------------------------------------------------------------------------------------------------------

While debugging, I see that the org.hibernate.impl.SessionFactoryImpl is returning the "Assigned" identifierGenerator. This is horrible. I've specified the identifierGenerator as "Auto". Please see the above code.


As a sidenote, I was trying to debug and seeing how the objects are getting retrieved from the database. Looks like the enrollmentgroupmembership records have the tierweight value populated. However if I look at the tierweight object, it doesn't have the enrollmentgroupmembership records. I'm puzzled. I think these two problems must be related.


Maddy.


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.