Temadown Wptr | Theme by mg12 | Valid XHTML 1.1 and CSS 3
  • JPA Sequence kullanımı

    JPA (Java persistence API) kullanırken entity ler uzerinde id leri sequence tan almak için aşağıdaki örneği inceleyebilirsiniz. Sequence yaratmak için “CREATE SEQUENCE User_SEQ;” komutu kullanılabilir.

       
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Id;
      import javax.persistence.SequenceGenerator;
       
      @Entity
      public class User {
        @SequenceGenerator(name="user_seq", sequenceName="User_SEQ")
        @Id @GeneratedValue(generator="user_seq")
        private int id;
       
        private String name;
       
        private long salary;
       
       
        public int getId() {
          return id;
        }
       
        public void setId(int id) {
          this.id = id;
        }
       
        public String getName() {
          return name;
        }
       
        public void setName(String name) {
          this.name = name;
        }
      }
    • del.icio.us
    • Facebook
    • Google
    • Digg
    • Mixx
    • Technorati
    • Live
    • Reddit
    • Sphinn
    • Furl
    Çarşamba, Aralık 24th, 2008 at 15:17
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
TOP