Remove-Delete issue with Cascade Type Remove for entity
nmatrix9 Sep 14, 2009 5:02 AMHello Seam Users,
I have to say before you refer me to the Hibernate documentation, yes I did read it and it did not prove effective in resolving my issue. I also followed the EJB 3 Developer guide and that has not proved use. I've also browsed through Google. Anyways my situation is this I have this database layout:
http://img245.imageshack.us/img245/2416/screenshotsp.png
I'm trying to not only remove the exoshellroles entity but also any connected children to that parent entity (i.e exoshellUserRoles). Anyways I read some hibernate and EJB3 documentation and I thought that setting a field with a cascade type of REMOVE (one to many) would be handled easily. When I execute this remove method for exoshellRoles entity:
@Override
public String remove() {
if(getInstance().getRoleId() == 1)
return "unable to delete";
try {
log.info("deleted role : #0", getInstance().getRoleName());
entityManager.remove(getInstance());
return "deleted";
} catch (Exception e) {
log.info("unable to delete: #0", e.getMessage());
FacesMessages.instance().add(
"unable to delete " + e.getMessage());
}
return null;
}
I end up getting this error:
26:11,924 ERROR [SeamPhaseListener] uncaught exception
javax.el.ELException: org.jboss.seam.framework.EntityNotFoundException: entity not found: com.domain.exoshellcms.entity.ExoshellRoles#304
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:333)
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:342)
at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:173)
at org.jboss.seam.navigation.Page.preRender(Page.java:275)
at org.jboss.seam.navigation.Pages.preRender(Pages.java:316)
at org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:560)
at org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:471)
at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:144)
at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:307)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
and here are the entities involved:
@Entity
@Name("userRoles")
@Table(name = "exoshell_user_roles", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = {
"module_id", "user_id", "role_id" }))
public class ExoshellUserRoles implements java.io.Serializable {
private int userRolesId;
private ExoshellUsers exoshellUsers;
private ExoshellRoles exoshellRoles;
private ExoshellModules exoshellModules;
public ExoshellUserRoles() {
}
public ExoshellUserRoles(int userRolesId, ExoshellUsers exoshellUsers,
ExoshellRoles exoshellRoles) {
this.userRolesId = userRolesId;
this.exoshellUsers = exoshellUsers;
this.exoshellRoles = exoshellRoles;
}
public ExoshellUserRoles(int userRolesId, ExoshellUsers exoshellUsers,
ExoshellRoles exoshellRoles, ExoshellModules exoshellModules) {
this.userRolesId = userRolesId;
this.exoshellUsers = exoshellUsers;
this.exoshellRoles = exoshellRoles;
this.exoshellModules = exoshellModules;
}
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name = "user_roles_id", unique = true, nullable = false)
@NotNull
public int getUserRolesId() {
return this.userRolesId;
}
public void setUserRolesId(int userRolesId) {
this.userRolesId = userRolesId;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
@NotNull
public ExoshellUsers getExoshellUsers() {
return this.exoshellUsers;
}
public void setExoshellUsers(ExoshellUsers exoshellUsers) {
this.exoshellUsers = exoshellUsers;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "role_id", nullable = false)
@NotNull
public ExoshellRoles getExoshellRoles() {
return this.exoshellRoles;
}
public void setExoshellRoles(ExoshellRoles exoshellRoles) {
this.exoshellRoles = exoshellRoles;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "module_id", nullable = true)
public ExoshellModules getExoshellModules() {
return this.exoshellModules;
}
public void setExoshellModules(ExoshellModules exoshellModules) {
this.exoshellModules = exoshellModules;
}
}
@Entity
@Name("users")
@Table(name = "exoshell_users", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = {
"username", "emailaddress" }))
public class ExoshellUsers implements java.io.Serializable {
private int userId;
private String username;
private String userpassword;
private String firstname;
private String lastname;
private String emailaddress;
private String userimage;
private byte[] picture;
private Date registered;
private String gender;
private Date lastLogin;
private String ipAddress;
private boolean accountenabled;
private Set exoshellUserRoleses = new HashSet(
0);
public ExoshellUsers() {
}
public ExoshellUsers(String username, String userpassword,
String firstname, String lastname, String emailaddress,
Date registered, String gender, Date lastLogin, String ipAddress,
boolean accountenabled) {
this.username = username;
this.userpassword = userpassword;
this.firstname = firstname;
this.lastname = lastname;
this.emailaddress = emailaddress;
this.registered = registered;
this.gender = gender;
this.lastLogin = lastLogin;
this.ipAddress = ipAddress;
this.accountenabled = accountenabled;
}
public ExoshellUsers(String username, String userpassword,
String firstname, String lastname, String emailaddress,
String userimage, Date registered, String gender, Date lastLogin,
String ipAddress, boolean accountenabled,
Set exoshellUserRoleses) {
this.username = username;
this.userpassword = userpassword;
this.firstname = firstname;
this.lastname = lastname;
this.emailaddress = emailaddress;
this.userimage = userimage;
this.registered = registered;
this.gender = gender;
this.lastLogin = lastLogin;
this.ipAddress = ipAddress;
this.accountenabled = accountenabled;
this.exoshellUserRoleses = exoshellUserRoleses;
}
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name = "user_id", unique = true, nullable = false)
@NotNull
public int getUserId() {
return this.userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
@Column(name = "username", nullable = false, length = 20)
@NotNull
@Length(max = 20)
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
@Column(name = "userpassword", nullable = false, length = 40)
@NotNull
@Length(max = 40)
public String getUserpassword() {
return this.userpassword;
}
public void setUserpassword(String userpassword) {
this.userpassword = userpassword;
}
@Column(name = "firstname", nullable = false, length = 40)
@NotNull
@Length(max = 40)
public String getFirstname() {
return this.firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
@Column(name = "lastname", nullable = false, length = 40)
@NotNull
@Length(max = 40)
public String getLastname() {
return this.lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
@Column(name = "emailaddress", nullable = false)
@NotNull
@Email(message="Input is not a valid email")
public String getEmailaddress() {
return this.emailaddress;
}
public void setEmailaddress(String emailaddress) {
this.emailaddress = emailaddress;
}
@Column(name = "userimage")
public String getUserimage() {
return this.userimage;
}
public void setUserimage(String userimage) {
this.userimage = userimage;
}
@Temporal(TemporalType.DATE)
@Column(name = "registered", nullable = false, length = 13)
@NotNull
public Date getRegistered() {
return this.registered;
}
public void setRegistered(Date registered) {
this.registered = registered;
}
@Column(name = "gender", nullable = false, length = 6)
@NotNull
@Length(max = 6)
public String getGender() {
return this.gender;
}
public void setGender(String gender) {
this.gender = gender;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_login", nullable = false, length = 29)
@NotNull
public Date getLastLogin() {
return this.lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
@Column(name = "ip_address", nullable = false, length = 32)
@NotNull
@Length(max = 32)
public String getIpAddress() {
return this.ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
@Column(name = "accountenabled", nullable = false)
@NotNull
public boolean isAccountenabled() {
return this.accountenabled;
}
public void setAccountenabled(boolean accountenabled) {
this.accountenabled = accountenabled;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "exoshellUsers")
public Set getExoshellUserRoleses() {
return this.exoshellUserRoleses;
}
public void setExoshellUserRoleses(
Set exoshellUserRoleses) {
this.exoshellUserRoleses = exoshellUserRoleses;
}
public byte[] getPicture() {
return picture;
}
public void setPicture(byte[] picture) {
this.picture = picture;
}
}
@Entity
@Name("roles")
@Table(name = "exoshell_roles", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = "role_name"))
public class ExoshellRoles implements java.io.Serializable {
private int roleId;
private String roleName;
private Set exoshellUserRoleses = new HashSet(
0);
public ExoshellRoles() {
}
public ExoshellRoles(String roleName) {
this.roleName = roleName;
}
public ExoshellRoles(String roleName,
Set exoshellUserRoleses) {
this.roleName = roleName;
this.exoshellUserRoleses = exoshellUserRoleses;
}
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name = "role_id", unique = true, nullable = false)
@NotNull
public int getRoleId() {
return this.roleId;
}
public void setRoleId(int roleId) {
this.roleId = roleId;
}
@Column(name = "role_name", unique = true, nullable = false, length = 30)
@NotNull
@Length(max = 30)
public String getRoleName() {
return this.roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "exoshellRoles", cascade=CascadeType.REMOVE)
public Set getExoshellUserRoleses() {
return this.exoshellUserRoleses;
}
public void setExoshellUserRoleses(
Set exoshellUserRoleses) {
this.exoshellUserRoleses = exoshellUserRoleses;
}
}
I have to say before you refer me to the Hibernate documentation, yes I did read it and it did not prove effective in resolving my issue. I also followed the EJB 3 Developer guide and that has not proved use. I've also browsed through Google. Anyways my situation is this I have this database layout:
http://img245.imageshack.us/img245/2416/screenshotsp.png
I'm trying to not only remove the exoshellroles entity but also any connected children to that parent entity (i.e exoshellUserRoles). Anyways I read some hibernate and EJB3 documentation and I thought that setting a field with a cascade type of REMOVE (one to many) would be handled easily. When I execute this remove method for exoshellRoles entity:
@Override
public String remove() {
if(getInstance().getRoleId() == 1)
return "unable to delete";
try {
log.info("deleted role : #0", getInstance().getRoleName());
entityManager.remove(getInstance());
return "deleted";
} catch (Exception e) {
log.info("unable to delete: #0", e.getMessage());
FacesMessages.instance().add(
"unable to delete " + e.getMessage());
}
return null;
}
I end up getting this error:
26:11,924 ERROR [SeamPhaseListener] uncaught exception
javax.el.ELException: org.jboss.seam.framework.EntityNotFoundException: entity not found: com.domain.exoshellcms.entity.ExoshellRoles#304
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:333)
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:342)
at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:173)
at org.jboss.seam.navigation.Page.preRender(Page.java:275)
at org.jboss.seam.navigation.Pages.preRender(Pages.java:316)
at org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:560)
at org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:471)
at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:144)
at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:307)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
and here are the entities involved:
@Entity
@Name("userRoles")
@Table(name = "exoshell_user_roles", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = {
"module_id", "user_id", "role_id" }))
public class ExoshellUserRoles implements java.io.Serializable {
private int userRolesId;
private ExoshellUsers exoshellUsers;
private ExoshellRoles exoshellRoles;
private ExoshellModules exoshellModules;
public ExoshellUserRoles() {
}
public ExoshellUserRoles(int userRolesId, ExoshellUsers exoshellUsers,
ExoshellRoles exoshellRoles) {
this.userRolesId = userRolesId;
this.exoshellUsers = exoshellUsers;
this.exoshellRoles = exoshellRoles;
}
public ExoshellUserRoles(int userRolesId, ExoshellUsers exoshellUsers,
ExoshellRoles exoshellRoles, ExoshellModules exoshellModules) {
this.userRolesId = userRolesId;
this.exoshellUsers = exoshellUsers;
this.exoshellRoles = exoshellRoles;
this.exoshellModules = exoshellModules;
}
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name = "user_roles_id", unique = true, nullable = false)
@NotNull
public int getUserRolesId() {
return this.userRolesId;
}
public void setUserRolesId(int userRolesId) {
this.userRolesId = userRolesId;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
@NotNull
public ExoshellUsers getExoshellUsers() {
return this.exoshellUsers;
}
public void setExoshellUsers(ExoshellUsers exoshellUsers) {
this.exoshellUsers = exoshellUsers;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "role_id", nullable = false)
@NotNull
public ExoshellRoles getExoshellRoles() {
return this.exoshellRoles;
}
public void setExoshellRoles(ExoshellRoles exoshellRoles) {
this.exoshellRoles = exoshellRoles;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "module_id", nullable = true)
public ExoshellModules getExoshellModules() {
return this.exoshellModules;
}
public void setExoshellModules(ExoshellModules exoshellModules) {
this.exoshellModules = exoshellModules;
}
}
@Entity
@Name("users")
@Table(name = "exoshell_users", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = {
"username", "emailaddress" }))
public class ExoshellUsers implements java.io.Serializable {
private int userId;
private String username;
private String userpassword;
private String firstname;
private String lastname;
private String emailaddress;
private String userimage;
private byte[] picture;
private Date registered;
private String gender;
private Date lastLogin;
private String ipAddress;
private boolean accountenabled;
private Set exoshellUserRoleses = new HashSet(
0);
public ExoshellUsers() {
}
public ExoshellUsers(String username, String userpassword,
String firstname, String lastname, String emailaddress,
Date registered, String gender, Date lastLogin, String ipAddress,
boolean accountenabled) {
this.username = username;
this.userpassword = userpassword;
this.firstname = firstname;
this.lastname = lastname;
this.emailaddress = emailaddress;
this.registered = registered;
this.gender = gender;
this.lastLogin = lastLogin;
this.ipAddress = ipAddress;
this.accountenabled = accountenabled;
}
public ExoshellUsers(String username, String userpassword,
String firstname, String lastname, String emailaddress,
String userimage, Date registered, String gender, Date lastLogin,
String ipAddress, boolean accountenabled,
Set exoshellUserRoleses) {
this.username = username;
this.userpassword = userpassword;
this.firstname = firstname;
this.lastname = lastname;
this.emailaddress = emailaddress;
this.userimage = userimage;
this.registered = registered;
this.gender = gender;
this.lastLogin = lastLogin;
this.ipAddress = ipAddress;
this.accountenabled = accountenabled;
this.exoshellUserRoleses = exoshellUserRoleses;
}
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name = "user_id", unique = true, nullable = false)
@NotNull
public int getUserId() {
return this.userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
@Column(name = "username", nullable = false, length = 20)
@NotNull
@Length(max = 20)
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
@Column(name = "userpassword", nullable = false, length = 40)
@NotNull
@Length(max = 40)
public String getUserpassword() {
return this.userpassword;
}
public void setUserpassword(String userpassword) {
this.userpassword = userpassword;
}
@Column(name = "firstname", nullable = false, length = 40)
@NotNull
@Length(max = 40)
public String getFirstname() {
return this.firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
@Column(name = "lastname", nullable = false, length = 40)
@NotNull
@Length(max = 40)
public String getLastname() {
return this.lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
@Column(name = "emailaddress", nullable = false)
@NotNull
@Email(message="Input is not a valid email")
public String getEmailaddress() {
return this.emailaddress;
}
public void setEmailaddress(String emailaddress) {
this.emailaddress = emailaddress;
}
@Column(name = "userimage")
public String getUserimage() {
return this.userimage;
}
public void setUserimage(String userimage) {
this.userimage = userimage;
}
@Temporal(TemporalType.DATE)
@Column(name = "registered", nullable = false, length = 13)
@NotNull
public Date getRegistered() {
return this.registered;
}
public void setRegistered(Date registered) {
this.registered = registered;
}
@Column(name = "gender", nullable = false, length = 6)
@NotNull
@Length(max = 6)
public String getGender() {
return this.gender;
}
public void setGender(String gender) {
this.gender = gender;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_login", nullable = false, length = 29)
@NotNull
public Date getLastLogin() {
return this.lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
@Column(name = "ip_address", nullable = false, length = 32)
@NotNull
@Length(max = 32)
public String getIpAddress() {
return this.ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
@Column(name = "accountenabled", nullable = false)
@NotNull
public boolean isAccountenabled() {
return this.accountenabled;
}
public void setAccountenabled(boolean accountenabled) {
this.accountenabled = accountenabled;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "exoshellUsers")
public Set getExoshellUserRoleses() {
return this.exoshellUserRoleses;
}
public void setExoshellUserRoleses(
Set exoshellUserRoleses) {
this.exoshellUserRoleses = exoshellUserRoleses;
}
public byte[] getPicture() {
return picture;
}
public void setPicture(byte[] picture) {
this.picture = picture;
}
}
@Entity
@Name("roles")
@Table(name = "exoshell_roles", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = "role_name"))
public class ExoshellRoles implements java.io.Serializable {
private int roleId;
private String roleName;
private Set exoshellUserRoleses = new HashSet(
0);
public ExoshellRoles() {
}
public ExoshellRoles(String roleName) {
this.roleName = roleName;
}
public ExoshellRoles(String roleName,
Set exoshellUserRoleses) {
this.roleName = roleName;
this.exoshellUserRoleses = exoshellUserRoleses;
}
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name = "role_id", unique = true, nullable = false)
@NotNull
public int getRoleId() {
return this.roleId;
}
public void setRoleId(int roleId) {
this.roleId = roleId;
}
@Column(name = "role_name", unique = true, nullable = false, length = 30)
@NotNull
@Length(max = 30)
public String getRoleName() {
return this.roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "exoshellRoles", cascade=CascadeType.REMOVE)
public Set getExoshellUserRoleses() {
return this.exoshellUserRoleses;
}
public void setExoshellUserRoleses(
Set exoshellUserRoleses) {
this.exoshellUserRoleses = exoshellUserRoleses;
}
}