create table users(
username varchar_ignorecase(50) not null primary key,
password varchar_ignorecase(50) not null,
enabled boolean not null);
create table authorities (
username varchar_ignorecase(50) not null,
authority varchar_ignorecase(50) not null,
constraint fk_authorities_users foreign key(username) references users(username));
create unique index ix_auth_username on authorities (username,authority);
到目前为止我得到的是:
<class name="com.foo.beans.User" table="users">
<id name="username" column="username"/>
<property name="password" column="password"/>
<property name="enabled" column="enabled"/>
</class>
<class name="com.foo.beans.Authority" table="authorities">
<composite-id name="ix_auth_username">
<key-property name="username" column="username" />
<key-property name="authority" column="authority" />
</composite-id>
</class>
知道我做错了什么吗?谢谢!
我建议使用注释而不是XML。XML有点过时了。
如果使用注释,将会是这样的:
@Entity
@Table(name="user_table")
public class User implements Serializable {
Long userId;
String username;
String password;
boolean enabled;
@Id
@Column(name="user_table_id")
public Long getUserId() { return userId; }
public void setUserId(Long id) { this.userId = userId; }
@Column(name="username", length=80, nullable=true)
public String getUsername() { return username };
public void setUsername(String username) { this.username = username; };
/* getters and settings annotated et cetera */
}
Authority很可能是user对象内部的惰性加载列表。
List<Authority> authorities;
@OneToMany(mappedBy="userId",
cascade=CascadeType.ALL,
fetch=FetchType.LAZY)
@OrderBy("xyz")
public List<Authority> getAuthorities() {
return authorities;
}
public void setAuthorities (List<Authority> authorities) { this.authorities = authorities; };
我编写了一个映射,如下所示: 当我运行应用程序时,会出现如下错误: 2012-05-15 17:12:38,651--WARN--失败的模式语句:创建表雇员(Id整数不为空auto_increment,版本日期时间不为空,FirstName nvarchar(300),LastName nvarchar(300),雇员类型nvarchar(300),主键(Id),唯一(firstName,last
b)对Employee类中的ReferencedColumnName='department id'使用@ManyToOne和@JoinColumn。 建议采用哪种方法?还是这两种方法用于完全不同的问题?
我有以下表格: id与具有一对一映射的成员_id相关。 我写了两个模型作为例子 登录模式: Memeber模型: 为了简单起见,我放弃了一些getter和setter。不管怎样,你能告诉我哪里出了问题吗?在更改注释值时,我会遇到诸如映射未找到、持久类未知等错误。 错误 org.springframework.web.util.NestedServletExc0019:请求处理失败;嵌套异常是org
我正在使用Hibernate和JPA注释来映射我的类。当hibernate尝试映射这个类时,我遇到了一个问题 我的Social alStat类是: 我得到了这个错误: 我猜发生这种情况是因为我试图映射到一个基本类,但@ElementCollection注释不应该解决这个问题吗? 我的item类如下所示:
本文向大家介绍JavaScript创建映射,包括了JavaScript创建映射的使用技巧和注意事项,需要的朋友参考一下 示例 映射是键到值的基本映射。映射与对象的不同之处在于,它们的键可以是任何东西(原始值和对象),而不仅仅是字符串和符号。Map上的迭代也总是按照将项目插入Map中的顺序进行,而在对象中的键上进行迭代时,顺序是不确定的。 要创建映射,请使用Map构造函数: 它具有一个可选参数,该参
我是Springmvc的初学者,我有两个jsp:-1。网络内容/索引。jsp:这很好用。索引文件具有超链接文本,如:- > 项目容器如下:- WebContent/WEB-INF/spring servlet。xml:- 我的问题:-当我从eclipse在tomcat服务器上运行这个项目时,索引文件显示得非常好。但由于索引文件中的文本与hello超链接。html我一直得到Http状态404。