EJB 单向一对多

package com.ericsson.iptv.streamtag.entity;
import java.io.Serializable;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "userinfo")
public class User implements Serializable {
    @Id
    @Column(name = "id")
    private int id;    
    @Column(name = "userId")
    private String userId;
    @Column(name = "userName")
    private String userName;
    @Column(name = "password")
    private String password;
    @Column(name = "watchingNow")
    private String watchingNow;
    @Column(name = "tagLevel")
    private int tagLevel;    
    @Column(name = "snsUserId")
    private String snsUserId;
    @Column(name = "snsId")
    private String snsId;
    
    @OneToMany(cascade = { CascadeType.ALL })
    @JoinTable(
       name="ref_user_friend",
       joinColumns={
                @JoinColumn(name="user_id",referencedColumnName="id")
       },
       inverseJoinColumns={
                @JoinColumn(name="friend_id",referencedColumnName="id")
       }
    )
    private Set<User> friendList = new HashSet<User>();

    public Set<User> getFriendList() {
              return friendList;
    }
    public void setFriendLit(Set<User> friendList) {
              this.friendList = friendList;
    }
    
    
    
    public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getWatchingNow() {
		return watchingNow;
	}
	public void setWatchingNow(String watchingNow) {
		this.watchingNow = watchingNow;
	}
    public int getTagLevel() {
		return tagLevel;
	}
	public void setTagLevel(int tagLevel) {
		this.tagLevel = tagLevel;
	}
	public String getSnsUserId() {
		return snsUserId;
	}
	public void setSnsUserId(String snsUserId) {
		this.snsUserId = snsUserId;
	}
	public String getSnsId() {
		return snsId;
	}
	public void setSnsId(String snsId) {
		this.snsId = snsId;
	}	
   
    
}

 

你可能感兴趣的:(ejb)