0
我有一個實體名稱爲「用戶」。由於Oracle無法創建具有該名稱的表,因此我將它賦予@Entity(name =)和@Table(name =)屬性以確保可以創建它。但是,由於某種原因,表格還沒有創建。爲了讓事情變得更爲奇怪,所有定義的@JoinTable都被正確創建,並帶有相應的名稱。任何人都有可能造成這種情況的想法?休眠不是在數據庫中創建一個命名的表格
我的類:
@Entity(name="USERTABLE")
@Table(name="USERTABLE")
public class User implements Serializable {
private static final long serialVersionUID = -3895959057511877608L;
private Integer id;
private String name;
private String userName;
private Domain domain;
private String password;
private Boolean mustChangePassword;
private String email;
// 19/07/2012 RP [WEAVER-83]
private Date lastLogin;
private List<Profile> profiles = new ArrayList<Profile>();
private List<Role> roles = new ArrayList<Role>();
@Id
@GeneratedValue(generator="user_seq")
@SequenceGenerator(name="user_seq",sequenceName="User_Sequence",allocationSize=1)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(unique = true)
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@ManyToOne
public Domain getDomain() {
return domain;
}
public void setDomain(Domain domain) {
this.domain = domain;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(columnDefinition = "tinyint")
public Boolean getMustChangePassword() {
return mustChangePassword;
}
public void setMustChangePassword(Boolean mustChangePassword) {
this.mustChangePassword = mustChangePassword;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
@ManyToMany
@JoinTable(joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "profile_id") })
@IndexColumn(name = "listOrder")
public List<Profile> getProfiles() {
return profiles;
}
public void setProfiles(List<Profile> profiles) {
this.profiles = profiles;
}
@ManyToMany
@JoinTable(joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id") })
@IndexColumn(name = "listOrder")
public List<Role> getRoles() {
return roles;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
}
我的persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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_1_0.xsd"
version="1.0">
<persistence-unit name="weaver">
<jta-data-source>java:/weaverDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<!-- <property name="hibernate.hbm2ddl.auto" value="update"/> -->
<property name="hibernate.hbm2ddl.auto" value="create"/>
<!-- http://www.jboss.com/index.html?module=bb&op=viewtopic&t=78806 -->
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.DefaultComponentSafeNamingStrategy"/>
</properties>
</persistence-unit>
</persistence>
更新:我嘗試創建一個命名策略,在每一個表的開始增加了一個前綴,但表保持受造