zoukankan      html  css  js  c++  java
  • spring_150909_hibernate_id_table

    1、新建java工程:spring_150909_hibernate_id_table,如下图所示:

    2、建DogPet实体类:

    package com.spring.model;
    
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.Table;
    import javax.persistence.TableGenerator;
    
    @Entity
    @Table(name="t_dog")
    public class DogPet {
        
        private int id;
        private String name;
        private int age;
        private String kind;
        private String sex;
        private String health;
        
        @Id  
        @GeneratedValue(strategy = GenerationType.TABLE, generator="pk_gen")   
        @TableGenerator(name="pk_gen",table="tb_generator"
                        ,pkColumnName="gen_name"
                        ,valueColumnName="gen_value"
                        ,pkColumnValue="PAYABLEMOENY_PK"
                        ,allocationSize=1)
        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;
        }
        public int getAge() {
            return age;
        }
        public void setAge(int age) {
            this.age = age;
        }
        public String getKind() {
            return kind;
        }
        public void setKind(String kind) {
            this.kind = kind;
        }
        public String getSex() {
            return sex;
        }
        public void setSex(String sex) {
            this.sex = sex;
        }
        public String getHealth() {
            return health;
        }
        public void setHealth(String health) {
            this.health = health;
        }
        
        public String toString()
        {
            return id+"--"+name+"--"+kind+"--"+age+"--"+health;
        }
    }
  • 相关阅读:
    android如何播放资源文件夹raw中的视频
    android studio添加三方jar包
    golang自动导入postgresql脚本
    xorm使用pgsql的例子
    python安装psycopg2
    制作u盘启动的工具
    codis须知
    redis3.0自带集群配置
    keepalive配置db层的ha的一些注意点
    phalcon安装笔记
  • 原文地址:https://www.cnblogs.com/yanff/p/4842130.html
Copyright © 2011-2022 走看看