Results 1 to 5 of 5
  1. #1
    rdheepan is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Primary key generation in jpa : sequence type.

    Hi All,
    I am Dheepan. Whenever i am generating primary key using @GeneratedValue and @Sequencegenerator,
    It is creating just random numbers instead of creating the sequence number as specified.. and some of
    my friends says that it will be generated in mySql but not in sql plus... Can somebody tell me why it is not
    creating the sequence numbers in sqlPlus? -Thanks in advance

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Primary key generation in jpa : sequence type.

    Cross posted at Jpa Primary key generation

  3. #3
    rdheepan is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Re: Primary key generation in jpa : sequence type.

    Since I am new to this forum i dont know the rules.. what should i do now?

  4. #4
    dinesh.guntha is offline Member
    Join Date
    May 2011
    Posts
    27
    Rep Power
    0

    Default Re: Primary key generation in jpa : sequence type.

    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    it will generate the sequence values.

  5. #5
    rdheepan is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Re: Primary key generation in jpa : sequence type.

    Thanks for your reply dinesh,
    I have used that syntax only.
    @GeneratedValue(strategy=GenerationType.SEQUENCE,g enerator="dheepan")
    @SequenceGenerator(initialValue=1,allocationSize=1 , name = "dheepan", sequenceName="dheepan")

    This is what i did. It should start from 1 and go on 2,3,4... like that in a sequence order .. but the numbers that are created was,
    401,0,52,273 like this it is creating some random numbers... It is on sql plus server..I heard that for MySql it is creating the exact values.. But i dont know why it is not working in sql plus? I am using sql plus..

Similar Threads

  1. JPA Primary Key from two foreign key
    By peterbo in forum New To Java
    Replies: 6
    Last Post: 06-29-2014, 11:30 AM
  2. Linked list sequence and array sequence
    By Predz in forum New To Java
    Replies: 1
    Last Post: 12-31-2009, 02:30 AM
  3. JPA Composite Primary Key
    By The_S in forum Advanced Java
    Replies: 2
    Last Post: 02-06-2009, 07:30 AM
  4. How to generate primary key in EJB
    By naresh_m in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 07-17-2008, 10:41 AM
  5. how to determine the primary key
    By osval in forum JDBC
    Replies: 1
    Last Post: 08-07-2007, 03:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •