Results 1 to 3 of 3
  1. #1
    nayal_java is offline Member
    Join Date
    Jul 2010
    Posts
    24
    Rep Power
    0

    Default Hibernate annotation non auto increment primary key column

    I want to map a column from my database as primary key which is not auto-increment.
    Please suggest me how to create hibernate annotation for this column

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,702
    Rep Power
    5

    Default Re: Hibernate annotation non auto increment primary key column

    Yes using Hibernate only, or through the Java Persistence API? Which DBMS exactly?

    Here's a tip: a question asked in one or two short sentences usually does not contain enough actual information to be able to provide an answer. Put a little more effort into it.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    nayal_java is offline Member
    Join Date
    Jul 2010
    Posts
    24
    Rep Power
    0

    Default Re: Hibernate annotation non auto increment primary key column

    I am using this hibernate annotation in my pojo but when I try to insert in database it is executing select query in console with primary key in where clause

    My pojo class:

    package in.nic.eservicebook.pojo;

    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.Table;

    Java Code:
    @Entity
    @Table(name = "wfempidentityp")
    public class WfEmpPrimaryIdentityDetails {
      private Integer titleCode;
      private String empShortName;
      private String empFullName;
      private Integer localEmpCode;
      
      
      @Column(name = "emp_title")
      public Integer getTitleCode() {
    	return titleCode;
    }
    public void setTitleCode(Integer titleCode) {
    	this.titleCode = titleCode;
    }
    
    @Column(name = "emp_shortname",length=30)
    public String getEmpShortName() {
    	return empShortName;
    }
    
    public void setEmpShortName(String empShortName) {
    	this.empShortName = empShortName;
    }
    
    @Column(name = "emp_fullname",length=75)
    public String getEmpFullName() {
    	return empFullName;
    }
    public void setEmpFullName(String empFullName) {
    	this.empFullName = empFullName;
    }
    
    @Id
    @Column(name = "localempcode")
    public Integer getLocalEmpCode() {
    	return localEmpCode;
    }
    public void setLocalEmpCode(Integer localEmpCode) {
    	this.localEmpCode = localEmpCode;
    }
    
    
    }

Similar Threads

  1. Replies: 2
    Last Post: 08-03-2013, 11:08 AM
  2. Setting Auto increment problem :(-:
    By asifzbaig in forum JDBC
    Replies: 0
    Last Post: 06-11-2011, 08:45 PM
  3. Auto sorting JTable by second column
    By d3n1s in forum Advanced Java
    Replies: 6
    Last Post: 05-06-2011, 01:56 AM
  4. Having trouble using annotation with Hibernate
    By ShinTec in forum Advanced Java
    Replies: 3
    Last Post: 09-06-2010, 03:34 AM
  5. How to create auto-increment
    By Albert in forum JDBC
    Replies: 2
    Last Post: 07-04-2007, 05:23 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
  •