1
我收到一個很奇怪的hibernate錯誤。我已經映射所有實體在我的MySQL數據庫感謝到Hibernate代碼生成,我已經建立了所有的關係,一切似乎工作,但現在我得到這個錯誤Hibernate的會話工廠並沒有識別標識符
org.hibernate.AnnotationException: No identifier specified for entity: com.YouDroop.Data.Entities.Showcase
at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:243)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:775)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3845)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3799)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1412)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1373)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.tools.hibernate.runtime.common.Util.invokeMethod(Util.java:43)
at org.jboss.tools.hibernate.runtime.common.AbstractConfigurationFacade.buildMappings(AbstractConfigurationFacade.java:160)
at org.hibernate.console.ConsoleConfiguration$4.execute(ConsoleConfiguration.java:272)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:108)
at org.hibernate.console.ConsoleConfiguration.buildMappings(ConsoleConfiguration.java:270)
at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(ConsoleConfigurationWorkbenchAdapter.java:44)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:98)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:104)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:232)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
在實體櫥窗是這個
@Entity
@Table(name = "showcase", schema = "youdroopnorelationships")
public class Showcase implements Serializable {
private static final long serialVersionUID = 1L;
private int code;
private Function function;
private String description;
private int capacity;
private int currentNumberOfProducts;
public Showcase() {
}
public Showcase(int code, Function function, int capacity, int currentNumberOfProducts) {
this.code = code;
this.function = function;
this.capacity = capacity;
this.currentNumberOfProducts = currentNumberOfProducts;
}
public Showcase(int code, Function function, String description, int capacity, int currentNumberOfProducts) {
this.code = code;
this.function = function;
this.description = description;
this.capacity = capacity;
this.currentNumberOfProducts = currentNumberOfProducts;
}
@Id
//@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "Code", unique = true, nullable = false)
public int getCode() {
return this.code;
}
public void setCode(int code) {
this.code = code;
}
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "Function_Name", nullable = false)
public Function getFunction() {
return this.function;
}
public void setFunction(Function function) {
this.function = function;
}
@Column(name = "Description", length = 100)
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
@Column(name = "Capacity", nullable = false)
public int getCapacity() {
return this.capacity;
}
public void setCapacity(int capacity) {
this.capacity = capacity;
}
@Column(name = "CurrentNumberOfProducts", nullable = false)
public int getCurrentNumberOfProducts() {
return this.currentNumberOfProducts;
}
public void setCurrentNumberOfProducts(int currentNumberOfProducts) {
this.currentNumberOfProducts = currentNumberOfProducts;
}
}
正如你可以看到我寫的所有註釋在正確的地方,即使是@Id之一,也是車.hbm文件體現了它。 當我重建Hibernate配置時出現錯誤,而如果我只刷新它,它可以工作,但不允許我看到會話工廠,由於這個錯誤。
我使用這個進口: 進口javax.persistence。*; import java.io. *; – MissArmstrong
你能告訴我你的數據庫表的代碼,所以也許我可以幫忙嗎? –
數據庫表在下面,它被稱爲Showcase – MissArmstrong