[Persistence, JBoss/CMP, Hibernate, Database] - hbm.xml
by ericmacau
Hello,
As I am a beginner in Hibernate and I usually used Annotated classes. I am now going to tried hbm.xml. Could you please to tell me how I can convert the following annotated classes into hbm.xml ?
| package mo.putoweb.model.account;
|
| import java.io.Serializable;
| import java.util.ArrayList;
| import java.util.Collection;
|
| import javax.persistence.CascadeType;
| import javax.persistence.Entity;
| import javax.persistence.FetchType;
| import javax.persistence.Id;
| import javax.persistence.JoinColumn;
| import javax.persistence.JoinTable;
| import javax.persistence.ManyToMany;
| import javax.persistence.Transient;
|
| @Entity
| public class User implements Serializable {
| public static final long serialVersionUID = 1L;
|
| private String username;
|
| private String password;
|
|
| private String firstName;
| private String lastName;
| private String displayName;
| private String gender;
|
|
| private boolean activate;
|
| private Collection<Role> roles = new ArrayList<Role>();
| private Collection<Group> groups = new ArrayList<Group>();
|
|
| @Transient
| public boolean isActivate() {
| return activate;
| }
|
|
| public boolean getActivate() {
| return activate;
| }
|
| public void setActivate(boolean activate) {
| this.activate = activate;
| }
|
| public String getPassword() {
| return password;
| }
|
| public void setPassword(String password) {
| this.password = password;
| }
|
| @Id
| //@GeneratedValue(strategy = GenerationType.AUTO)
| public String getUsername() {
| return username;
| }
|
| public void setUsername(String username) {
| this.username = username;
| }
|
|
|
| public String getFirstName() {
| return firstName;
| }
|
| public void setFirstName(String firstName) {
| this.firstName = firstName;
| }
|
| public String getLastName() {
| return lastName;
| }
|
| public void setLastName(String lastName) {
| this.lastName = lastName;
| }
|
|
|
|
| public String getDisplayName() {
| return displayName;
| }
|
| public void setDisplayName(String displayName) {
| this.displayName = displayName;
| }
|
|
|
|
|
| public String getGender() {
| return gender;
| }
|
| public void setGender(String gender) {
| this.gender = gender;
| }
|
| @ManyToMany(cascade = {CascadeType.REMOVE},
| fetch = FetchType.EAGER,
| targetEntity=Role.class)
| @JoinTable(
| name="USER_ROLE_LINK",
| joinColumns={@JoinColumn(name="username")},
| inverseJoinColumns={@JoinColumn(name="rolename")}
| )
| public Collection<Role> getRoles() {
| return roles;
| }
|
| public void setRoles(Collection<Role> roles) {
| this.roles = roles;
| }
|
| @Transient
| public void addRole(Role role) {
| this.roles.add(role);
| }
|
|
| @ManyToMany(cascade = {CascadeType.REMOVE},
| fetch = FetchType.LAZY,
| targetEntity=Group.class)
| @JoinTable(
| name="USER_GROUP_LINK",
| joinColumns={@JoinColumn(name="username")},
| inverseJoinColumns={@JoinColumn(name="groupname")}
| )
| public Collection<Group> getGroups() {
| return groups;
| }
|
|
| public void setGroups(Collection<Group> groups) {
| this.groups = groups;
| }
|
| @Transient
| public void addGroup(Group group) {
| groups.add(group);
| }
|
| }
|
| package mo.putoweb.model.account;
|
| import java.io.Serializable;
| import java.util.ArrayList;
| import java.util.Collection;
|
| import javax.persistence.Entity;
| import javax.persistence.FetchType;
| import javax.persistence.Id;
| import javax.persistence.JoinColumn;
| import javax.persistence.JoinTable;
| import javax.persistence.ManyToMany;
| import javax.persistence.Transient;
|
| @Entity
| public class Role implements Serializable {
| public static final long serialVersionUID = 1L;
|
| private String roleName;
| private String description;
|
| private Collection<User> users = new ArrayList<User>();
|
| public String getDescription() {
| return description;
| }
|
| public void setDescription(String description) {
| this.description = description;
| }
|
| @Id
| public String getRoleName() {
| return roleName;
| }
|
| public void setRoleName(String roleName) {
| this.roleName = roleName;
| }
|
| @ManyToMany(
| targetEntity=User.class,
| mappedBy="roles",
| fetch = FetchType.EAGER)
| @JoinTable(
| name="USER_ROLE_LINK",
| joinColumns={@JoinColumn(name="rolename")},
| inverseJoinColumns={@JoinColumn(name="username")}
| )
| public Collection<User> getUsers() {
| return users;
| }
|
| public void setUsers(Collection<User> users) {
| this.users = users;
| }
|
| @Transient
| public void addUser(User user) {
| this.users.add(user);
| }
|
|
|
|
| }
|
|
| package mo.putoweb.model.account;
|
| import java.io.Serializable;
| import java.util.ArrayList;
| import java.util.Collection;
|
| import javax.persistence.Entity;
| import javax.persistence.FetchType;
| import javax.persistence.Id;
| import javax.persistence.JoinColumn;
| import javax.persistence.JoinTable;
| import javax.persistence.ManyToMany;
| import javax.persistence.Table;
| import javax.persistence.Transient;
|
| @Entity
| @Table(name = "UserGroup")
| public class Group implements Serializable {
| private static final long serialVersionUID = 1L;
|
| private String groupName;
|
| private String description;
|
| private Collection<User> users = new ArrayList<User>();
|
| public String getDescription() {
| return description;
| }
|
| public void setDescription(String description) {
| this.description = description;
| }
|
| @Id
| public String getGroupName() {
| return groupName;
| }
|
| public void setGroupName(String groupName) {
| this.groupName = groupName;
| }
|
| @ManyToMany(fetch = FetchType.LAZY, mappedBy="groups")
| @JoinTable(
| name="USER_GROUP_LINK",
| joinColumns={@JoinColumn(name="groupname")},
| inverseJoinColumns={@JoinColumn(name="username")}
| )
| public Collection<User> getUsers() {
| return users;
| }
|
| public void setUsers(Collection<User> users) {
| this.users = users;
| }
|
| @Transient
| public void addUser(User user) {
| users.add(user);
| }
|
| }
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970952#3970952
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970952
19 years, 7 months
[JBoss Eclipse IDE (users)] - Cannot start JBoss4 Server from IDE2
by humanlikerobot
I can start JBossServer from command prompt.
C:\jboss4\bin > run.bat
....server start.
I can see http://localhost:8080/
But!! I can't start JBossServer from IDE "JBoss Server View".
Right click on the server icon, and choose "start" menu.
It begin to start and I can see logging in Console View.
After log message say "Start in XXm XXms.",
server status is "Starting" yet.
After seconds, Error message appear.
"JBoss Server failed to start."
server status returns "Stopped".
C:\jboss4\server\default\log\server.log
[BOF]
...
...
...
2006-09-12 18:05:17,953 INFO [org.jboss.system.server.Server] JBoss (MX MicroKernel) [4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)] Started in 22s:407ms
2006-09-12 18:05:19,687 DEBUG [org.jboss.security.auth.spi.UsersRolesLoginModule] Loaded properties, users=[admin]
2006-09-12 18:05:19,687 DEBUG [org.jboss.security.auth.spi.UsersRolesLoginModule] Loaded properties, users=[admin]
2006-09-12 18:05:19,703 DEBUG [org.jboss.security.auth.spi.UsersRolesLoginModule] Bad password for username=null
...
...
...
2006-09-12 18:06:21,640 DEBUG [org.jboss.security.auth.spi.UsersRolesLoginModule] Loaded properties, users=[admin]
2006-09-12 18:06:21,640 DEBUG [org.jboss.security.auth.spi.UsersRolesLoginModule] Loaded properties, users=[admin]
2006-09-12 18:06:21,640 DEBUG [org.jboss.security.auth.spi.UsersRolesLoginModule] Bad password for username=null
[EOF]
following. my environment.
Eclipse 3.2
JBoss 4.0.4
Java EE 5
Windows XP
Sorry about poor English.
Help me please.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970951#3970951
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970951
19 years, 7 months
[JBoss Seam] - Re: seam + ajax4jsf + facelets
by cayo
hello tobad,
the configuration as described above works fine, but I have no conversation propagation anymore after changing my web.xml like that.
Do you have the same problem, or even a hint for me? this is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!-- Seam -->
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
<!-- Propagate conversations across redirects -->
<filter-name>Seam Redirect Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
<filter-mapping>
<filter-name>Seam Redirect Filter</filter-name>
<url-pattern>*.seam</url-pattern>
</filter-mapping>
<!-- JSF MyFaces -->
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<!-- Faces Servlet Mapping -->
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.seam</url-pattern>
</servlet-mapping>
<servlet-name>Seam Remoting</servlet-name>
<servlet-class>org.jboss.seam.remoting.SeamRemotingServlet</servlet-class>
<servlet-mapping>
<servlet-name>Seam Remoting</servlet-name>
<url-pattern>/seam/remoting/*</url-pattern>
</servlet-mapping>
<!-- MyFaces -->
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/tomahawk.taglib.xml; /WEB-INF/rossmann.taglib.xml</param-value>
</context-param>
<!-- projects own servlet -->
<servlet-name>MonitorServlet</servlet-name>
<servlet-class>de.rossmann.productlisting.servlet.ShowMonitorServlet</servlet-class>
<load-on-startup>2</load-on-startup>
<servlet-mapping>
<servlet-name>MonitorServlet</servlet-name>
<url-pattern>*.jpeg</url-pattern>
</servlet-mapping>
<!-- Ajax4JSF Initial parameters -->
<display-name>Ajax4jsf Filter</display-name>
<filter-name>ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.framework.ajax.xmlfilter.NekkoFilter</filter-class>
<init-param>
<param-name>forceparser</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>enable-cache</param-name>
<param-value>false</param-value>
</init-param>
<filter-mapping>
<filter-name>ajax4jsf</filter-name>
<url-pattern>*.seam</url-pattern>
</filter-mapping>
<context-param>
<param-name>org.ajax4jsf.SKIN</param-name>
<param-value>DEFAULT</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<session-config>
<session-timeout>600</session-timeout>
</session-config>
<error-page>
<exception-type>
javax.servlet.ServletException
</exception-type>
/productlisting/timeout.seam
</error-page>
</web-app>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970943#3970943
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970943
19 years, 7 months