Reputation: 660
Today i have new problem with JPA/EJB3. I have 2 table User
and Group
with mapping OneToMany
(Group One - User Many)
When I use select statement in EJB, for example:
@NamedQuery(name = "Iuser.findAll", query = "SELECT i FROM Iuser i")
a conflict occur, it not know group
field I choose where table? (group
field in User
Table is groupid
[foreign key] and group
field in Group
table is Group
[Primary Key])
How can i solve this problem?
I know user user.group
button statement in EJB3 not execute, please help.
Upvotes: 1
Views: 202
Reputation: 570565
My bet is that the IGroup
entity is mapped on the table Group
which is a reserved keyword and might cause problems if not escaped.
If you're using a JPA 2.0 provider, you can tell the JPA provider to escape the database object name by enclosing the name within double quotes, like this:
@Entity
@Table(name="\"GROUP\"")
public class IGroup {
...
}
If you're using JPA 1.0, there is no standardized way, it depends on the JPA provider. With Hibernate, you'd have to use backticks:
@Entity
@Table(name="`GROUP`")
public class IGroup {
...
}
Or, change the table name for a non reserved keyword:
@Entity
@Table(name="GROUPS")
public class IGroup {
...
}
Does it make sense?
Upvotes: 2