Java 仅当部署到Heroku时,mappedBy Hibernate错误
我有一个使用Hibernate、ClearDBMySQL和Heroku的简单Java项目。当我通过Eclipse在本地运行(Tomcat 9.0)时,一切都正常(包括检索持久化对象),但一旦我部署到Heroku,我就会在我的一个OneToMany连接上收到Hibernate“mappedBy reference a unknown target entity property” 以下是部署时(由Main.java HttpServlet捕获并打印)得到的堆栈跟踪错误:Java 仅当部署到Heroku时,mappedBy Hibernate错误,java,hibernate,heroku,Java,Hibernate,Heroku,我有一个使用Hibernate、ClearDBMySQL和Heroku的简单Java项目。当我通过Eclipse在本地运行(Tomcat 9.0)时,一切都正常(包括检索持久化对象),但一旦我部署到Heroku,我就会在我的一个OneToMany连接上收到Hibernate“mappedBy reference a unknown target entity property” 以下是部署时(由Main.java HttpServlet捕获并打印)得到的堆栈跟踪错误: [PersistenceU
[PersistenceUnit:coloradotaghunter\u管理器]无法构建Hibernate
会话工厂
由…引起的。。。
mappedBy引用未知的目标实体属性:com.coloradotaghunter.gmu.tags中的com.coloradotaghunter.Tag.gmu
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249)
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120)
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860)
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:75)
persistence.persistence.createEntityManagerFactory(persistence.java:79)
persistence.persistence.createEntityManagerFactory(persistence.java:54)
TagHunterService.(TagHunterService.java:30)
doGet(Main.java:23)
javaservlet.http.HttpServlet.service(HttpServlet.java:635)
javaservlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
run(Thread.java:748)
下面是涉及的Gmu(父对象)和标记(子对象)对象:
Gmu.java
/**
* Gmu generated by hbm2java
*/
@Entity
@Table(name = "gmu", catalog = "heroku_74dfffe65503eee")
public class Gmu implements java.io.Serializable {
/**
*
*/
// private static final long serialVersionUID = -501255736919935566L;
private int gmuNbr;
private String regionCode;
private Set<HarvestEstimate> harvestEstimates = new HashSet<HarvestEstimate>(0);
private Set<Tag> tags = new HashSet<Tag>(0);
public Gmu() {
}
public Gmu(int gmuNbr) {
this.gmuNbr = gmuNbr;
}
public Gmu(int gmuNbr, Set<HarvestEstimate> harvestEstimates, Set<Tag> tags) {
this.gmuNbr = gmuNbr;
this.harvestEstimates = harvestEstimates;
this.tags = tags;
}
@Id
@Column(name = "gmu_nbr", unique = true, nullable = false)
public int getGmuNbr() {
return this.gmuNbr;
}
public void setGmuNbr(int gmuNbr) {
this.gmuNbr = gmuNbr;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "gmu")
public Set<HarvestEstimate> getHarvestEstimates() {
return this.harvestEstimates;
}
public void setHarvestEstimates(Set<HarvestEstimate> harvestEstimates) {
this.harvestEstimates = harvestEstimates;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "gmu")
public Set<Tag> getTags() {
return this.tags;
}
public void setTags(Set<Tag> tags) {
this.tags = tags;
}
@Column(name = "region_code", nullable = true, length = 45)
public String getRegionCode() {
return regionCode;
}
public void setRegionCode(String regionCode) {
this.regionCode = regionCode;
}
}
/**
*hbm2java生成的Gmu
*/
@实体
@表(name=“gmu”,catalog=“Heroku74DFFFE65503EEE”)
公共类Gmu实现java.io.Serializable{
/**
*
*/
//私有静态最终长serialVersionUID=-501255736919935566L;
私有int GMUNB;
私有字符串区域码;
私有集=新哈希集(0);
私有集标记=新哈希集(0);
公共Gmu(){
}
公共Gmu(国际Gmu){
this.gmunb=gmunb;
}
公共Gmu(整数GMUNB、集合估计、集合标记){
this.gmunb=gmunb;
this.harvestEstimates=harvestEstimates;
this.tags=标签;
}
@身份证
@列(name=“gmu\u nbr”,unique=true,nullable=false)
public int getGmuNbr(){
返回此.gmunb;
}
公共无效设置GMUNB(int GMUNB){
this.gmunb=gmunb;
}
@OneToMany(fetch=FetchType.LAZY,mappedBy=“gmu”)
公共集getHarvestEstimates(){
返回此文件,以获取估计值;
}
公共无效setHarvestEstimates(集合harvestEstimates){
this.harvestEstimates=harvestEstimates;
}
@OneToMany(fetch=FetchType.LAZY,mappedBy=“gmu”)
公共集getTags(){
返回此.tags;
}
公共无效集合标记(集合标记){
this.tags=标签;
}
@列(name=“region\u code”,null=true,长度=45)
公共字符串getRegionCode(){
返回区域代码;
}
公共无效setRegionCode(字符串regionCode){
this.regionCode=regionCode;
}
}
Tag.java
/**
* Tag generated by hbm2java
*/
@Entity
@Table(name = "tag", catalog = "heroku_74dfffe65503eee")
public class Tag implements java.io.Serializable {
/**
*
*/
// private static final long serialVersionUID = -5962836863381745774L;
private String tagCode;
private Gmu gmu;
private char methodCode;
private char seasonTypeCode;
private int seasonNbr;
private char speciesCode;
private char genderCode;
private char listCode;
private Set<DrawResult> drawResults = new HashSet<DrawResult>(0);
public Tag() {
}
public Tag(String tagCode, Gmu gmu, char methodCode, char seasonTypeCode, int seasonNbr, char speciesCode,
char genderCode, char listCode) {
this.tagCode = tagCode;
this.gmu = gmu;
this.methodCode = methodCode;
this.seasonTypeCode = seasonTypeCode;
this.seasonNbr = seasonNbr;
this.speciesCode = speciesCode;
this.genderCode = genderCode;
this.listCode = listCode;
}
public Tag(String tagCode, Gmu gmu, char methodCode, char seasonTypeCode, int seasonNbr, char speciesCode,
char genderCode, char listCode, Set<DrawResult> drawResults) {
this.tagCode = tagCode;
this.gmu = gmu;
this.methodCode = methodCode;
this.seasonTypeCode = seasonTypeCode;
this.seasonNbr = seasonNbr;
this.speciesCode = speciesCode;
this.genderCode = genderCode;
this.listCode = listCode;
this.drawResults = drawResults;
}
@Id
@Column(name = "tag_code", unique = true, nullable = false, length = 10)
public String getTagCode() {
return this.tagCode;
}
public void setTagCode(String tagCode) {
this.tagCode = tagCode;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gmu_nbr", nullable = false)
public Gmu getGmu() {
return this.gmu;
}
public void setGmu(Gmu gmu) {
this.gmu = gmu;
}
@Column(name = "method_code", nullable = false, length = 1)
public char getMethodCode() {
return this.methodCode;
}
public void setMethodCode(char methodCode) {
this.methodCode = methodCode;
}
@Column(name = "season_type_code", nullable = false, length = 1)
public char getSeasonTypeCode() {
return this.seasonTypeCode;
}
public void setSeasonTypeCode(char seasonTypeCode) {
this.seasonTypeCode = seasonTypeCode;
}
@Column(name = "season_nbr", nullable = false)
public int getSeasonNbr() {
return this.seasonNbr;
}
public void setSeasonNbr(int seasonNbr) {
this.seasonNbr = seasonNbr;
}
@Column(name = "species_code", nullable = false, length = 1)
public char getSpeciesCode() {
return this.speciesCode;
}
public void setSpeciesCode(char speciesCode) {
this.speciesCode = speciesCode;
}
@Column(name = "gender_code", nullable = false, length = 1)
public char getGenderCode() {
return this.genderCode;
}
public void setGenderCode(char genderCode) {
this.genderCode = genderCode;
}
@Column(name = "list_code", nullable = false, length = 1)
public char getListCode() {
return this.listCode;
}
public void setListCode(char listCode) {
this.listCode = listCode;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "tag")
public Set<DrawResult> getDrawResults() {
return this.drawResults;
}
public void setDrawResults(Set<DrawResult> drawResults) {
this.drawResults = drawResults;
}
}
/**
*由hbm2java生成的标记
*/
@实体
@表(name=“tag”,catalog=“heroku_74dfffe65503eee”)
公共类标记实现java.io.Serializable{
/**
*
*/
//私有静态最终长serialVersionUID=-5962836863381745774L;
私有字符串标记码;
私人Gmu Gmu;
私有字符方法码;
私有字符类型码;
私人住宅;
私有字符规范;
私有字符性别码;
私有字符列表码;
私有集drawResults=新哈希集(0);
公共标签(){
}
公共标记(字符串标记代码、Gmu Gmu、char方法代码、char季节类型代码、int季节NBR、char规范代码、,
字符性别代码,字符列表代码){
this.tagCode=tagCode;
this.gmu=gmu;
this.methodCode=methodCode;
this.seasonTypeCode=seasonTypeCode;
this.sensitenbr=sensitenbr;
this.speciesCode=speciesCode;
this.genderCode=genderCode;
this.listCode=list
/**
* Tag generated by hbm2java
*/
@Entity
@Table(name = "tag", catalog = "heroku_74dfffe65503eee")
public class Tag implements java.io.Serializable {
/**
*
*/
// private static final long serialVersionUID = -5962836863381745774L;
private String tagCode;
private Gmu gmu;
private char methodCode;
private char seasonTypeCode;
private int seasonNbr;
private char speciesCode;
private char genderCode;
private char listCode;
private Set<DrawResult> drawResults = new HashSet<DrawResult>(0);
public Tag() {
}
public Tag(String tagCode, Gmu gmu, char methodCode, char seasonTypeCode, int seasonNbr, char speciesCode,
char genderCode, char listCode) {
this.tagCode = tagCode;
this.gmu = gmu;
this.methodCode = methodCode;
this.seasonTypeCode = seasonTypeCode;
this.seasonNbr = seasonNbr;
this.speciesCode = speciesCode;
this.genderCode = genderCode;
this.listCode = listCode;
}
public Tag(String tagCode, Gmu gmu, char methodCode, char seasonTypeCode, int seasonNbr, char speciesCode,
char genderCode, char listCode, Set<DrawResult> drawResults) {
this.tagCode = tagCode;
this.gmu = gmu;
this.methodCode = methodCode;
this.seasonTypeCode = seasonTypeCode;
this.seasonNbr = seasonNbr;
this.speciesCode = speciesCode;
this.genderCode = genderCode;
this.listCode = listCode;
this.drawResults = drawResults;
}
@Id
@Column(name = "tag_code", unique = true, nullable = false, length = 10)
public String getTagCode() {
return this.tagCode;
}
public void setTagCode(String tagCode) {
this.tagCode = tagCode;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gmu_nbr", nullable = false)
public Gmu getGmu() {
return this.gmu;
}
public void setGmu(Gmu gmu) {
this.gmu = gmu;
}
@Column(name = "method_code", nullable = false, length = 1)
public char getMethodCode() {
return this.methodCode;
}
public void setMethodCode(char methodCode) {
this.methodCode = methodCode;
}
@Column(name = "season_type_code", nullable = false, length = 1)
public char getSeasonTypeCode() {
return this.seasonTypeCode;
}
public void setSeasonTypeCode(char seasonTypeCode) {
this.seasonTypeCode = seasonTypeCode;
}
@Column(name = "season_nbr", nullable = false)
public int getSeasonNbr() {
return this.seasonNbr;
}
public void setSeasonNbr(int seasonNbr) {
this.seasonNbr = seasonNbr;
}
@Column(name = "species_code", nullable = false, length = 1)
public char getSpeciesCode() {
return this.speciesCode;
}
public void setSpeciesCode(char speciesCode) {
this.speciesCode = speciesCode;
}
@Column(name = "gender_code", nullable = false, length = 1)
public char getGenderCode() {
return this.genderCode;
}
public void setGenderCode(char genderCode) {
this.genderCode = genderCode;
}
@Column(name = "list_code", nullable = false, length = 1)
public char getListCode() {
return this.listCode;
}
public void setListCode(char listCode) {
this.listCode = listCode;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "tag")
public Set<DrawResult> getDrawResults() {
return this.drawResults;
}
public void setDrawResults(Set<DrawResult> drawResults) {
this.drawResults = drawResults;
}
}