java 休眠注释编译错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5480128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
hibernate annotations compile error
提问by othman
I'm encountering a strange problem when i try to compile a DTO file which has hibernate annotations to map to db . when fails with a strange message log below. what could be the cause of this problem? i suppose the error comes from file CashDTO . what am i doing wrong in file CashDTO.java?
当我尝试编译具有休眠注释以映射到 db 的 DTO 文件时,我遇到了一个奇怪的问题。当失败并显示下面的奇怪消息日志时。这个问题的原因是什么?我想错误来自文件 CashDTO 。我在文件 CashDTO.java 中做错了什么?
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Version;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
/**
* @author othmanelmoulat
*
*/
@Entity
@TableGenerator(name = "cash_GEN", table = "jbilling_seqs", pkColumnName = "name", valueColumnName = "next_id", pkColumnValue = "cash", allocationSize = 100)
@Table(name = "cash")
public class CashDTO implements Serializable {
int id;
BigDecimal amount;
Date date;
int versionNum;
public CashDTO() {
super();
// TODO Auto-generated constructor stub
}
public CashDTO(int id) {
super();
this.id = id;
}
public CashDTO(int id, BigDecimal amount, Date date) {
super();
this.id = id;
this.amount = amount;
this.date = date;
}
public CashDTO(int id, BigDecimal amount, Date date, int versionNum) {
super();
this.id = id;
this.amount = amount;
this.date = date;
this.versionNum = versionNum;
}
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "cash_GEN")
@Column(name = "id", unique = true, nullable = false)
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "amount", nullable = false)
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
@Column(name = "date", nullable = false)
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
@Version
@Column(name = "OPTLOCK")
public int getVersionNum() {
return versionNum;
}
public void setVersionNum(int versionNum) {
this.versionNum = versionNum;
}
}
Error log:
错误日志:
Buildfile: /Users/othmanelmoulat/Documents/workspace/jbilling/src/build.xml
init:
[delete] Deleting directory /Users/othmanelmoulat/Documents/workspace/jbilling/src/build/test-results
[mkdir] Created dir: /Users/othmanelmoulat/Documents/workspace/jbilling/src/build/test-results
compile_api:
[javac] /Users/othmanelmoulat/Documents/workspace/jbilling/src/build.xml:272: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
findRevision:
jar_api:
[jar] Building jar: /Users/othmanelmoulat/Documents/workspace/jbilling/src/build/deploy/jbilling_api.jar
test-ws:
[javac] /Users/othmanelmoulat/Documents/workspace/jbilling/src/build.xml:457: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 7 source files to /Users/othmanelmoulat/Documents/workspace/jbilling/src/build/test
[javac] com/sapienter/jbilling/server/user/db/CashDTO.class(com/sapienter/jbilling/server/user/db:CashDTO.class): warning: Cannot find annotation method 'name()' in type 'javax.persistence.TableGenerator': class file for javax.persistence.TableGenerator not found
[javac] com/sapienter/jbilling/server/user/db/CashDTO.class(com/sapienter/jbilling/server/user/db:CashDTO.class): warning: Cannot find annotation method 'table()' in type 'javax.persistence.TableGenerator'
[javac] com/sapienter/jbilling/server/user/db/CashDTO.class(com/sapienter/jbilling/server/user/db:CashDTO.class): warning: Cannot find annotation method 'pkColumnName()' in type 'javax.persistence.TableGenerator'
[javac] com/sapienter/jbilling/server/user/db/CashDTO.class(com/sapienter/jbilling/server/user/db:CashDTO.class): warning: Cannot find annotation method 'valueColumnName()' in type 'javax.persistence.TableGenerator'
[javac] com/sapienter/jbilling/server/user/db/CashDTO.class(com/sapienter/jbilling/server/user/db:CashDTO.class): warning: Cannot find annotation method 'pkColumnValue()' in type 'javax.persistence.TableGenerator'
[javac] com/sapienter/jbilling/server/user/db/CashDTO.class(com/sapienter/jbilling/server/user/db:CashDTO.class): warning: Cannot find annotation method 'allocationSize()' in type 'javax.persistence.TableGenerator'
[javac] com/sapienter/jbilling/server/user/db/CashDTO.class(com/sapienter/jbilling/server/user/db:CashDTO.class): warning: Cannot find annotation method 'name()' in type 'javax.persistence.Table': class file for javax.persistence.Table not found
[javac] com/sapienter/jbilling/server/user/db/CashDTO.class(com/sapienter/jbilling/server/user/db:CashDTO.class): warning: Cannot find annotation method 'strategy()' in type 'javax.persistence.GeneratedValue': class file for javax.persistence.GeneratedValue not found
[javac] An exception has occurred in the compiler (1.6.0_24). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
[javac] com.sun.tools.javac.code.Symbol$CompletionFailure: class file for javax.persistence.GenerationType not found
BUILD FAILED
/Users/othmanelmoulat/Documents/workspace/jbilling/src/build.xml:457: Compile failed; see the compiler error output for details.
Total time: 5 seconds
采纳答案by matt b
Sounds like the classes for javax.persistence
are not on the classpath of the javac
task in your test-ws
Ant target.
听起来像 for 的类javax.persistence
不在javac
您的test-ws
Ant 目标中的任务的类路径上。