Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Uses a non-entity as target entity

917543Feb 14 2012 — edited Feb 17 2012
Hi everyone,

I need your help because I am working on a project j2ee6

I am using jpa (eclipseLink)

when I created entities without relation, all worked perfectly

but now that I am trying to set up relation @oneTomany @ManyToOne

I got this error all the time

Exception Description: [class com.Domain.User] uses
[ERROR] a non-entity [class com.Domain.Groups] as target entity in the
[ERROR] relationship attribute [field groupe].


here is my user entity :_

@Entity
@NamedQueries({
@NamedQuery(name = "findAllUsers", query="select u from User u"),
@NamedQuery(name = "findWithLogParam", query="select u from User u where u.Email = :fmail and u.Password = FUNC('sha1', :fpass)")
})
public class User implements Serializable{

/**
*
*/
private static final long serialVersionUID = 3175161374832714727L;

@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Long UserId;
@Column(nullable = false)
private String Title = "Mr";
@Column(nullable = false)
private String Login;
@Column(nullable = false)
private String Password;
@Column(nullable = false)
private String Firstname;
@Column(nullable = false)
private String Lastname;
@Column(nullable = false)
private String Email;
private String Telephone;
private String Mobile;
@Temporal(TemporalType.DATE)
private Date Date_of_birth;
private String Postcode;
private String Address;
private String City;
private String County;
private String Region;
private String Country;
private String AccountEnabled="On";

@ManyToOne(optional=false)
@JoinColumn(name="GROUPID", referencedColumnName="GROUPID")
private Groups groupe;
private String Token;

Here is the entity Groups*

@Entity
public class Groups implements Serializable{


private static final long serialVersionUID = 7092895671981671161L;

@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Long GroupId;
@Column(nullable = false)
private String GroupName;

@OneToMany(mappedBy="groupe", targetEntity=User.class, fetch=FetchType.EAGER)
private List<User> UserList = new ArrayList<User>();

Here is my persistence.xml*

<?xml version="1.0" encoding="windows-1252" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="testPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/UnmodDB</jta-data-source>
<class>com.unmod.Domain.User</class>
<class>com.unmod.Domain.Groups</class>
........ other classes ......
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-database" value="MySQL"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.create-ddl-jdbc-file-name" value="create.sql"/>
</properties>
</persistence-unit>
</persistence>


It works (compliation works) when I add @Basic however only the user table is created

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 16 2012
Added on Feb 14 2012
12 comments
6,541 views