问题描述
我的问题是,它看起来像是出于某种原因,应用程序没有看到数据库中的一个coulmns,我的控制台一直告诉我有一个语法错误。我认为引起麻烦的表是连接列(下面你会看到我的数据库实现)。
在这里,我将复制保持堆栈跟踪,以便您看到发生了什么:
$ b
只需再次检查,我将粘贴我的领域配置以及数据库和用于创建它的实体。
领域
>数据库和实体
包实体;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name =USERS,schema =ADMIN)
public class User implements Serializable {
private static final long serialVersionUID = -1244856316278032177L;
@Id
@Column(nullable = false)
私有字符串userid;
@Column(nullable = false)
私人字符串密码;
@ManyToOne
@JoinTable(NAME = USER_GROUP 模式= ADMIN,joinColumns = @JoinColumn(名称= 用户id,referencedColumnName = 用户id),inverseJoinColumns = @ JoinColumn(name =groupid,referencedColumnName =groupid))
私人群组;
public String getUserid(){
return userid;
}
public void setUserid(String userid){
this.userid = userid;
}
public String getPassword(){
return password;
}
public void setPassword(String password){
this.password = password;
}
public Group getGroup(){
return group;
}
public void setGroup(Group group){
this.group = group;
包实体;
import java.io.Serializable;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name =GROUPS,schema =ADMIN)
public class Group implements Serializable {
private static final long serialVersionUID = -7274308564659753174L;
@Id
@Column(nullable = false)
private String groupid;
@OneToMany(mappedBy =group)
private Set< User>用户;
public String getGroupid(){
return groupid;
}
public void setGroupid(String groupid){
this.groupid = groupid;
}
public Set< User> getUsers(){
返回用户;
}
public void setUsers(Set< User> users){
this.users = users;
$ b $ p
$ b 这是控制台在使用选项generate来自实体的表格:
lockquote
EL Config:设置持久化类[class
entities.Group]的访问类型到[FIELD]。 [EL配置]:一对多映射元素[字段用户]的目标实体
(引用)类默认为:class entities.User。 [EL配置]:持久类[class entities.User]的访问类型
被设置为[FIELD]。 [EL
Config]:多对一
映射元素[字段组]的目标实体(引用)类默认为:class
entities.Group。 [EL Config]:实体类
[class entities.Group]的别名默认为:Group。 [EL配置]:元素[field groupid]的
列名默认为:
GROUPID。 [EL Config]:实体类[class
entities.User]的别名默认为:User。 [EL配置]:元素[字段用户标识]的列
名称默认为:USERID。 [EL
Config]:元素[字段密码]的列名称是
,默认为:PASSWORD。 [EL警告]:PersistenceUnitInfo第12章
容器管理的身份验证和授权具有transactionType
RESOURCE_LOCAL,因此jtaDataSource将被忽略[EL Info]:
EclipseLink,版本:Eclipse持久性服务 -
2.0.1.v20100213-r6600 [EL Fine]:检测到的供应商平台:org.eclipse.persistence.platform.database.JavaDBPlatform [EL配置]:
连接(25292190) - 连接(DatabaseLogin(
platform => JavaDBPlatform user name =>userdatasource URL =>
jdbc:derby:// localhost:1527 / studydb; create = true))[EL Config]:
连接(18306082) - 连接:
jdbc:derby:// localhost:1527 / studydb; create = true用户:user数据库:
Apache Derby版本:10.5.3.0 - (802917)驱动程序:Apache Derby
网络客户端JDBC驱动程序版本:10.5.3.0 - (802917)[EL配置]:
连接(9740137) - 连接(DatabaseLogin(
platform => JavaDBPlatform user name =>user datasource URL =>
$ jbc:derby:// localhost:1527 / studydb; create = true))[EL Config]:
连接(23965177) - 连接:
jdbc:derby:// localhost: 1527 / studydb; create = true用户:user数据库:
Apache Derby版本:10.5.3.0 - (802917)驱动程序:Apache Derby
网络客户端JDBC驱动程序版本:10.5.3.0 - (802917)[EL信息]:
文件:/ C:/ learningJSF / CHAPTER x 12容器管理认证和
授权/构建/类/ _CHAPTER x 12容器管理
认证和
Authorization_url = jdbc :derby:// localhost:1527 / studydb; create = true_user = user
登录成功[EL Fine]:连接(18306082) - ALTER TABLE
ADMIN.USER_GROUP DROP CONSTRAINT USER_GROUP_groupid [EL Fine]:
连接(18306082) - ALTER TABLE ADMIN.USER_GROUP DROP约束
USER_GROUP_userid [EL精细]:连接(18306082) - DROP TABLE
ADMIN.USER_GROUP [EL精细]:连接(18306082 ) - CREATE TABLE
ADMIN.USER_GROUP(userid VARCHAR(255)NOT NULL, groupid VARCHAR(255)
NOT NULL,PRIMARY KEY(userid,groupid))[EL Fine]:
Connection(18306082) - DROP TABLE ADMIN.USERS [EL Fine]:
连接(18306082) - CREATE TABLE ADMIN.USERS(USERID VARCHAR(255)
NOT NULL,PASSWORD VARCHAR(255)NOT NULL,PRIMARY KEY(USERID))[EL
Fine]:Connection(18306082) --DROP TABLE ADMIN.GROUPS [EL Fine]:
连接(18306082) - CREATE TABLE ADMIN.GROUPS(GROUPID VARCHAR(255)
NOT NULL,PRIMARY KEY(GROUPID))[EL Fine] :
连接(18306082) - ALTER TABLE ADMIN.USER_GROUP ADD约束
USER_GROUP_groupid外键(组识别符号)参考ADMIN.GROUPS
(组识别符号)[EL精细]:连接(18306082) - ALTER TABLE
ADMIN.USER_GROUP ADD CONSTRAINT USER_GROUP_userid FOREIGN KEY(userid)
REFERENCES ADMIN.USERS(userid)[EL Config]:
Connection(18306082) - disconnect [EL Info]:
文件:/ C:/ learningJSF / CHAPTER x 12 Container Managed Authentication and
Authorization / build / classes / _CHAPTE R x 12容器管理
认证和
Authorization_url = jdbc:derby:// localhost:1527 / studydb; create = true_user = user
注销成功[EL Config]:连接(25292190) - -disconnect [EL
Config]:Connection(23965177) - disconnect
这是我的其余配置,也许它也有帮助:
真的很感谢您的帮助。
Im being a few days struggling to create my first Security realm in glassfish V3.
My problem is that it looks like for some reason, the application does not see the one of the coulmns in the database, and my console keeps telling me that there is a syntax error. I think the table that is making me trouble is the join column(Below you will see my DB implementation).
Here i will copy the hold stack trace so you will see what is going on:
Just to check once more, here i will paste my realm configuration and also the database and the entities used to create it.
Realm
Database and entities
package entities;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name="USERS", schema="ADMIN")
public class User implements Serializable {
private static final long serialVersionUID = -1244856316278032177L;
@Id
@Column(nullable = false)
private String userid;
@Column(nullable = false)
private String password;
@ManyToOne
@JoinTable(name="USER_GROUP",schema="ADMIN", joinColumns = @JoinColumn(name="userid", referencedColumnName="userid"), inverseJoinColumns=@JoinColumn(name="groupid", referencedColumnName= "groupid") )
private Group group;
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Group getGroup() {
return group;
}
public void setGroup(Group group) {
this.group = group;
}
}
package entities;
import java.io.Serializable;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name="GROUPS", schema="ADMIN")
public class Group implements Serializable {
private static final long serialVersionUID = -7274308564659753174L;
@Id
@Column(nullable = false)
private String groupid;
@OneToMany(mappedBy="group")
private Set<User> users;
public String getGroupid() {
return groupid;
}
public void setGroupid(String groupid) {
this.groupid = groupid;
}
public Set<User> getUsers() {
return users;
}
public void setUsers(Set<User> users) {
this.users = users;
}
}
This is what the console displays when using the option generate Tables from entities:
And this is the rest of my configuration, maybe it helps too:
Ill really appreciate your help.
解决方案 Try to type ADMIN.USERS and ADMIN.USER_GROUP in realm settings. It will tell GlasshFish the schema, where your tables are stored.
这篇关于无法为JDBC领域加载组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!