zoukankan      html  css  js  c++  java
  • Hibernate 简单的annotation

    package com.itmyhome.model;
    
    import java.util.Date;
    
    import javax.persistence.Basic;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.Table;
    import javax.persistence.Temporal;
    import javax.persistence.TemporalType;
    import javax.persistence.Transient;
    
    @Entity
    @Table(name="_teacher")
    public class Teacher {
    	private int id;
    	private String name;
    	private String address;
    	private Date birthday;
    	/*
    	 * ID
    	 * 其他默认全部映射 默认为@Basic
    	 */
    	@Id
    	public int getId() {
    		return id;
    	}
    	public void setId(int id) {
    		this.id = id;
    	}
    	@Basic
    	public String getName() {
    		return name;
    	}
    	public void setName(String name) {
    		this.name = name;
    	}
    	/*
    	 * 如果不想让其字段映射到数据表中 可使用Transient
    	 */
    	@Transient
    	public String getAddress() {
    		return address;
    	}
    	public void setAddress(String address) {
    		this.address = address;
    	}
    	/*
    	 * 设置时间的类型  有DATE,TIME,TIMESTAMP
    	 */
    	@Temporal(TemporalType.DATE)
    	public Date getBirthday() {
    		return birthday;
    	}
    	public void setBirthday(Date birthday) {
    		this.birthday = birthday;
    	}
    	
    	
    }
    


  • 相关阅读:
    Python-单例模式
    Django 内置模板标签和过滤器
    Python Built-in Function 学习笔记
    Django 中间件
    Django Form
    Ajax
    Django中cookie和session
    Django中的QuerySet
    Django模型和ORM
    wordpress添加子主题
  • 原文地址:https://www.cnblogs.com/itmyhome/p/4131516.html
Copyright © 2011-2022 走看看