Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is the first entity
- package org.domain.newseam.entity;
- import java.util.Date;
- import javax.persistence.Column;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import static javax.persistence.GenerationType.IDENTITY;
- import javax.persistence.Id;
- import javax.persistence.JoinColumn;
- import javax.persistence.ManyToOne;
- import javax.persistence.Table;
- import javax.persistence.Temporal;
- import javax.persistence.TemporalType;
- import org.jboss.seam.ScopeType;
- import org.jboss.seam.annotations.Name;
- import org.jboss.seam.annotations.Scope;
- import org.domain.newseam.entity.User;
- @Entity
- @Scope(ScopeType.SESSION)
- @Name("multichoice")
- @Table(name = "multichoice", schema = "billmanager")
- public class Multichoice implements java.io.Serializable {
- private Integer id;
- private String cardno;
- private String description;
- private double amount;
- private int user_id;
- private Date date;
- private String tnumber;
- private User user;
- public Multichoice() {
- }
- public Multichoice(String cardno, String description, double amount,
- int userId, Date date, String tnumber) {
- this.cardno = cardno;
- this.description = description;
- this.amount = amount;
- this.user_id = userId;
- this.date = date;
- this.tnumber = tnumber;
- }
- @Id
- @GeneratedValue(strategy = IDENTITY)
- @Column(name = "id", unique = true, nullable = false)
- public Integer getId() {
- return this.id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- @Column(name = "cardno", nullable = false, length = 50)
- public String getCardno() {
- return this.cardno;
- }
- public void setCardno(String cardno) {
- this.cardno = cardno;
- }
- @Column(name = "description", nullable = false, length = 65535)
- public String getDescription() {
- return this.description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- @Column(name = "amount", nullable = false, precision = 22, scale = 0)
- public double getAmount() {
- return this.amount;
- }
- public void setAmount(double amount) {
- this.amount = amount;
- }
- @Column(name = "user_id", nullable = false, updatable=false )
- public int getUser_id() {
- return user_id;
- }
- public void setUser_id(int user_id) {
- this.user_id = user_id;
- }
- @Temporal(TemporalType.DATE)
- @Column(name = "date", nullable = false, length = 10)
- public Date getDate() {
- return this.date;
- }
- public void setDate(Date date) {
- this.date = date;
- }
- @Column(name = "tnumber", nullable = false, length = 12)
- public String getTnumber() {
- return this.tnumber;
- }
- public void setTnumber(String tnumber) {
- this.tnumber = tnumber;
- }
- @ManyToOne
- @JoinColumn(name="user_id")
- public User getUser() {
- return user;
- }
- public void setUser(User user) {
- this.user = user;
- }
- }
- //and this is the 2nd entity
- package org.domain.newseam.entity;
- // Generated 19-Apr-2011 14:44:53 by Hibernate Tools 3.4.0.CR1
- import java.util.HashSet;
- import java.util.Set;
- import javax.persistence.Column;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.OneToMany;
- import static javax.persistence.GenerationType.IDENTITY;
- import javax.persistence.Id;
- import javax.persistence.Table;
- import javax.persistence.UniqueConstraint;
- import org.hibernate.validator.Email;
- import org.hibernate.validator.Length;
- import org.hibernate.validator.NotNull;
- import org.jboss.seam.ScopeType;
- import org.jboss.seam.annotations.Name;
- import org.jboss.seam.annotations.Scope;
- import org.domain.newseam.entity.*;
- import javax.persistence.JoinColumn;
- import javax.persistence.JoinTable;
- import javax.persistence.ManyToMany;
- import org.jboss.seam.annotations.security.management.UserEnabled;
- import org.jboss.seam.annotations.security.management.UserFirstName;
- import org.jboss.seam.annotations.security.management.UserLastName;
- import org.jboss.seam.annotations.security.management.UserPassword;
- import org.jboss.seam.annotations.security.management.UserPrincipal;
- import org.jboss.seam.annotations.security.management.UserRoles;
- import org.jboss.security.integration.password.Password;
- /**
- * User generated by hbm2java
- */
- @Entity
- @Scope(ScopeType.SESSION)
- @Name("user")
- @Table(name = "user", schema = "billmanager", uniqueConstraints = {
- @UniqueConstraint(columnNames = "email"),
- @UniqueConstraint(columnNames = "username") })
- public class User implements java.io.Serializable {
- private Integer id;
- private String firstname;
- private String lastname;
- private String address1;
- private String address2;
- private String city;
- private String state;
- private String zip;
- private String phone;
- private String email;
- private String username;
- private String password;
- private int usertype;
- private String password2;
- private Set<Multichoice> multichoices = new HashSet<Multichoice>();
- private Set<Roles> roles;
- public User() {
- }
- public User(String firstname, String lastname, String address1,
- String address2, String city, String state, String zip,
- String phone, String email, String username, String password,
- int usertype) {
- this.firstname = firstname;
- this.lastname = lastname;
- this.address1 = address1;
- this.address2 = address2;
- this.city = city;
- this.state = state;
- this.zip = zip;
- this.phone = phone;
- this.email = email;
- this.username = username;
- this.password = password;
- this.usertype = usertype;
- }
- @Id
- @GeneratedValue(strategy = IDENTITY)
- @Column(name = "id", unique = true, nullable = false)
- public Integer getId() {
- return this.id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- @Column(name = "firstname", nullable = false, length = 100)
- @NotNull
- @Length(max = 100)
- public String getFirstname() {
- return this.firstname;
- }
- public void setFirstname(String firstname) {
- this.firstname = firstname;
- }
- @Column(name = "lastname", nullable = false, length = 100)
- @NotNull
- @Length(max = 100)
- public String getLastname() {
- return this.lastname;
- }
- public void setLastname(String lastname) {
- this.lastname = lastname;
- }
- @Column(name = "address1", nullable = false, length = 200)
- @NotNull
- @Length(max = 200)
- public String getAddress1() {
- return this.address1;
- }
- public void setAddress1(String address1) {
- this.address1 = address1;
- }
- @Column(name = "address2", nullable = true, length = 200)
- @NotNull
- @Length(max = 200)
- public String getAddress2() {
- return this.address2;
- }
- public void setAddress2(String address2) {
- this.address2 = address2;
- }
- @Column(name = "city", nullable = false, length = 200)
- @NotNull
- @Length(max = 200)
- public String getCity() {
- return this.city;
- }
- public void setCity(String city) {
- this.city = city;
- }
- @Column(name = "state", nullable = false, length = 50)
- @NotNull
- @Length(max = 50)
- public String getState() {
- return this.state;
- }
- public void setState(String state) {
- this.state = state;
- }
- @Column(name = "zip", nullable = false, length = 15)
- @NotNull
- @Length(max = 15)
- public String getZip() {
- return this.zip;
- }
- public void setZip(String zip) {
- this.zip = zip;
- }
- @Column(name = "phone", nullable = false, length = 20)
- @NotNull
- @Length(max = 20)
- public String getPhone() {
- return this.phone;
- }
- public void setPhone(String phone) {
- this.phone = phone;
- }
- @Column(name = "email", unique = true, nullable = false, length = 40)
- @NotNull
- @Length(max = 40)
- @Email
- public String getEmail() {
- return this.email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- @Column(name = "username", unique = true, nullable = false, length = 25)
- @NotNull
- @Length(max = 25)
- @UserPrincipal
- public String getUsername() {
- return this.username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- @Column(name = "password", nullable = false, length = 25)
- @NotNull
- @Length(max = 45)
- @UserPassword(hash="sha")
- public String getPassword() {
- return this.password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- @Column(name = "usertype", nullable = false)
- public int getUsertype() {
- return this.usertype;
- }
- public void setUsertype(int usertype) {
- this.usertype = usertype;
- }
- @UserRoles
- @ManyToMany
- @JoinTable(name = "userrolelink", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"))
- public Set<Roles> getRoles() {
- return roles;
- }
- public void setRoles(Set<Roles> roles) {
- this.roles = roles;
- }
- public String getPassword2() {
- return password2;
- }
- public void setPassword2(String password2) {
- this.password2 = password2;
- }
- @OneToMany(mappedBy="user")
- public Set<Multichoice> getMultichoices() {
- return multichoices;
- }
- public void setMultichoices(Set<Multichoice> multichoices) {
- this.multichoices = multichoices;
- }
- }
Add Comment
Please, Sign In to add comment