-->
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: Sequenzen
PostPosted: Wed Dec 02, 2015 7:58 am 
Newbie

Joined: Wed Dec 02, 2015 6:01 am
Posts: 3
Hallo,

ich habe folgendes mapping:
Code:
    @Id
    @Column(name = "ID", unique = true, nullable = false, precision = 28, scale = 0)
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "sequence-identity",
        parameters = @Parameter(name = "sequence", value = "BS_SEQ_KL_ID"))
    public long getId() {
        return this.id;
    }

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


Es funktioniert, bringt mir aber eine Warnung:
Code:
WARN org.hibernate.orm.deprecation - HHH90000014: Found use of deprecated [org.hibernate.id.SequenceIdentityGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead.  See Hibernate Domain Model Mapping Guide for details.


wenn ich es daraufhin der Doku entsprechend umbaue:
Code:
    @Id
    @Column(name = "ID", unique = true, nullable = false, precision = 28, scale = 0)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BS_SEQ_KL_ID")
    @SequenceGenerator(name = "BS_SEQ_KL_ID", sequenceName = "BS_SEQ_KL_ID")
    public long getId() {
        return this.id;
    }

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

Erhalte ich bei einem Insert einen Fehler:
Code:
org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session

Ich denke die Ursache ist, dass es die erzeugte ID bereits existiert. Was mache ich hier falsch?

Viele Grüße


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.