zoukankan      html  css  js  c++  java
  • HSQLDB JPA GeneratedValue

    使用 hSQLDB

    CREATE TABLE HIBERNATE_SEQUENCES
    (
    SEQUENCE_NAME VARCHAR(255) NOT NULL,
    SEQUENCE_NEXT_HI_VALUE BIGINT NOT NULL
    );

     @GeneratedValue(strategy = GenerationType.TABLE)

    默写要建立缺省表

     1 package com.hantongchao.entity;
     2 
     3 import javax.persistence.*;
     4 import java.util.HashSet;
     5 import java.util.Set;
     6 
     7 /**
     8  * Created by han on 14-3-6.
     9  */
    10 @Entity
    11 @Table(name = "USER", schema = "PUBLIC", catalog = "PUBLIC")
    12 public class UserEntity {
    13     private int user_id;
    14     private String name;
    15     private String surname;
    16     private Set<AccountEntity> accountEntities = new HashSet<AccountEntity>();
    17 
    18 
    19 
    20     @Id
    21     @Column(name = "User_ID", nullable = false, insertable = true, updatable = true, length = 32, precision = 0)
    22   /*  @GeneratedValue(strategy = GenerationType.TABLE,generator="userIdGen")
    23     @TableGenerator(name="userIdGen",table = "Tb_Generator",catalog = "PUBLIC",
    24             schema = "PUBLIC",pkColumnName = "gen_name",  valueColumnName = "gen_value",
    25             pkColumnValue = "user_pk" ,allocationSize = 1)
    26 */
    27     @GeneratedValue(strategy = GenerationType.TABLE)
    28     public int getUser_id() {
    29         return user_id;
    30     }
    31 
    32     public void setUser_id(int user_id) {
    33         this.user_id = user_id;
    34     }
    35     @Basic
    36     @Column(name = "NAME", nullable = false, insertable = true, updatable = true, length = 45, precision = 0)
    37     public String getName() {
    38         return name;
    39     }
    40 
    41     public void setName(String name) {
    42         this.name = name;
    43     }
    44 
    45     @Basic
    46     @Column(name = "SURNAME", nullable = false, insertable = true, updatable = true, length = 45, precision = 0)
    47     public String getSurname() {
    48         return surname;
    49     }
    50 
    51     public void setSurname(String surname) {
    52         this.surname = surname;
    53     }
    54 
    55 
    56 
    57     @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER ,mappedBy = "user")
    58     public Set<AccountEntity> getAccountEntities() {
    59         return accountEntities;
    60     }
    61 
    62     public void setAccountEntities(Set<AccountEntity> accountEntities) {
    63         this.accountEntities = accountEntities;
    64     }
    65 
    66     public UserEntity addAccount(AccountEntity accountEntity){
    67         accountEntity.setUser(this);
    68         this.getAccountEntities().add(accountEntity);
    69         return this;
    70     }
    71 
    72 }
    View Code
  • 相关阅读:
    grep命令
    Linux下tar.xz结尾的文件的解压方法
    const char*, char const*, char*const的区别
    "undefined reference to" 多种可能出现的问题解决方法
    Linux查找含有某字符串的所有文件
    Netbeans C++ unable to resolve identifier 无法解析标识符
    Linux 下编译C程序的全过程
    linux tar.gz zip 解压缩 压缩命令
    安装anaconda
    Mongodb数据迁移步骤
  • 原文地址:https://www.cnblogs.com/cndavy/p/3594294.html
Copyright © 2011-2022 走看看