⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user.java

📁 一个运营支持决算系统(BIOS)的源码
💻 JAVA
字号:
package com.netctoss.liping.userManage;

import java.sql.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.*;

import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;
/**
 * 用户管理模块 采用的是hibernateAnnotation的方式映射数据
 * User实体类的设计:
 * login_name是唯一的
 * 1 map 的查询:1>findByLoginNameAndPass 2>findByLoginName 3>findUserByUserId 4>updateStatusById
 * 2 不能自己更新的属性:id,login_name,status(0:正常,1:暂停,2:删除),关联的对象services ,enroll_date,close_date
 * 3 不能为空的属性:id,login_name,login_password,name,gender(0,1),status(0:正常,1:暂停,2:删除),email
 * 4 延迟加载的属性:enroll_date,close_date,关联的对象services 
 * 5 不需要生成insert的属性:enroll_date,close_date,关联的对象services
 */

@Entity
@Table(name="liping_user")

@NamedQueries(value={
		@NamedQuery(name = "findByLoginNameAndPass", query = "from User u where u.login_name=? and u.login_password= ?"),
		@NamedQuery(name = "findByLoginName", query = "from User u where u.login_name=?"),
		@NamedQuery(name = "findUserByUserId", query = " select u from User u left join fetch u.services where u.id=?")}
		)
public class User {
	  

	@Id
	@GeneratedValue( strategy=GenerationType.AUTO)
	@Column(name="user_id" ,updatable=false ,nullable=false)
	private Long id;
	
	@Column(nullable=false)
	private String name;
	
	@Column(updatable=false,nullable=false,unique=true)
	private String login_name;
	
	@Column(nullable=false)
	private String login_password;
	
	@Column(updatable=false,nullable=false)
	private int status;
	
	private String phone;
	
	@Column(updatable=false)
	private String email;
	
	@Basic( fetch = FetchType.LAZY)
	@Column(updatable=false,insertable=false)
	
	private Date enroll_date;
	
	@Basic( fetch = FetchType.LAZY )
	@Column(updatable=false,insertable=false)
	
	private Date close_date;
	
	private int payment_style;
	private String career;
	private String nationality;
	
	@Column(updatable=false)
	private String gender;
	private String company;
	private String address;
	private String post_code;
	
	//与userService 关联
	@OneToMany( fetch=FetchType.LAZY, mappedBy="user",targetEntity=com.netctoss.liping.userManage.UserService.class)
	private Set<UserService> services = new HashSet<UserService>();
	
	public void addUserService( UserService us){
		
		if( services==null ){
			services =  new HashSet<UserService>();
		}
		if( us!=null ){
			services.add( us );
			us.setUser(this);
	    }
	
}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the login_name
	 */
	public String getLogin_name() {
		return login_name;
	}

	/**
	 * @param login_name the login_name to set
	 */
	public void setLogin_name(String login_name) {
		this.login_name = login_name;
	}

	/**
	 * @return the login_password
	 */
	public String getLogin_password() {
		return login_password;
	}

	/**
	 * @param login_password the login_password to set
	 */
	public void setLogin_password(String login_password) {
		this.login_password = login_password;
	}

	/**
	 * @return the status
	 */
	public int getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(int status) {
		this.status = status;
	}

	/**
	 * @return the phone
	 */
	public String getPhone() {
		return phone;
	}

	/**
	 * @param phone the phone to set
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the enroll_date
	 */
	public Date getEnroll_date() {
		return enroll_date;
	}

	/**
	 * @param enroll_date the enroll_date to set
	 */
	public void setEnroll_date(Date enroll_date) {
		this.enroll_date = enroll_date;
	}

	/**
	 * @return the close_date
	 */
	public Date getClose_date() {
		return close_date;
	}

	/**
	 * @param close_date the close_date to set
	 */
	public void setClose_date(Date close_date) {
		this.close_date = close_date;
	}

	/**
	 * @return the payment_style
	 */
	public int getPayment_style() {
		return payment_style;
	}

	/**
	 * @param payment_style the payment_style to set
	 */
	public void setPayment_style(int payment_style) {
		this.payment_style = payment_style;
	}

	/**
	 * @return the career
	 */
	public String getCareer() {
		return career;
	}

	/**
	 * @param career the career to set
	 */
	public void setCareer(String career) {
		this.career = career;
	}

	/**
	 * @return the nationality
	 */
	public String getNationality() {
		return nationality;
	}

	/**
	 * @param nationality the nationality to set
	 */
	public void setNationality(String nationality) {
		this.nationality = nationality;
	}

	/**
	 * @return the gender
	 */
	public String getGender() {
		return gender;
	}

	/**
	 * @param gender the gender to set
	 */
	public void setGender(String gender) {
		this.gender = gender;
	}

	/**
	 * @return the company
	 */
	public String getCompany() {
		return company;
	}

	/**
	 * @param company the company to set
	 */
	public void setCompany(String company) {
		this.company = company;
	}

	/**
	 * @return the address
	 */
	public String getAddress() {
		return address;
	}

	/**
	 * @param address the address to set
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * @return the post_code
	 */
	public String getPost_code() {
		return post_code;
	}

	/**
	 * @param post_code the post_code to set
	 */
	public void setPost_code(String post_code) {
		this.post_code = post_code;
	}

	/**
	 * @return the services
	 */
	public Set<UserService> getServices() {
		return services;
	}

	/**
	 * @param services the services to set
	 */
	public void setServices(Set<UserService> services) {
		this.services = services;
	}

	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -