I am trying to create a Flex/Java/Hibernate project using mySQL, BlazeDS and Tomcat server. I have gotten all of that to work. But as soon as I put in tags for @OneToMany, my project breaks. A lot of the example projects I have seen have created a hbm file with one-to-many mappings. But they are usually much older websites or blog writings, like from 2006 or 2007. So my question is, in the current day, how would I set up a project that needs to map a java file to a OneToMany mapping.
AbstractUser.java:
Code:
public class AbstractUser {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "userID", nullable = false)
private Long userID;
@Basic
@Column(name = "first_name", nullable = true, unique = false)
private String firstName;
@Basic
@Column(name = "last_name", nullable = true, unique = false)
private String lastName;
@Basic
@Column(name = "type", nullable = true, unique = false)
private String type;
@Basic
@Column(name = "username", nullable = true, unique = false)
private String username;
@Basic
@Column(name = "password", nullable = true, unique = false)
private String password;
@CollectionOfElements(targetElement = com.pegasus.tms.materials.CourseSession.class)
@OneToMany(mappedBy="abstractUser", targetEntity=com.pegasus.tms.materials.CourseSession.class, cascade=CascadeType.ALL, fetch=FetchType.EAGER)
Collection<CourseSession> courses;
CourseSession.java:
Code:
public class CourseSession {
@ManyToOne(fetch=FetchType.EAGER)
private AbstractUser abstractUser;
@Basic
@Column(name = "courseID", nullable = true, unique = false)
private Long courseID;
@Basic
@Column(name = "percentComplete", nullable = true, unique = false)
private int percentComplete;
@Basic
@Column(name = "lastPage", nullable = true, unique = false)
private String lastPage;
@Basic
@Column(name = "expiration", nullable = true, unique = false)
private String expiration;
public CourseSession() {
super();
}
Again the second I add in the @ManyToOne and @OneToMany, I get the following persistence error in Flex:
Quote:
[RPC Fault faultString="javax.persistence.PersistenceException : [PersistenceUnit: tms] Unable to configure EntityManagerFactory" faultCode="Server.Processing" faultDetail="null"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at NetConnectionMessageResponder/statusHandler()
at mx.messaging::MessageResponder/status()
TIA