У меня есть простой Java-проект, использующий Hibernate, ClearDB MySQL и Heroku.Когда я запускаю локально (Tomcat 9.0) через Eclipse, все работает (включая извлечение постоянного объекта), но после развертывания в Heroku я получаю Hibernate «ссылка mappedBy на неизвестное целевое свойство объекта» в одном из моих объединений OneToMany.
Вот ошибка с трассировкой стека, которую я получаю при развертывании (как перехвачено и распечатано моим HttpServlet Main.java):
[PersistenceUnit: coloradotaghunter_manager] Unable to build Hibernate
SessionFactory
Caused by...
mappedBy reference an unknown target entity property: com.coloradotaghunter.Tag.gmu in com.coloradotaghunter.Gmu.tags
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)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
com.coloradotaghunter.TagHunterService.<init>(TagHunterService.java:30)
Main.doGet(Main.java:23)
javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
javax.servlet.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)
java.lang.Thread.run(Thread.java:748)
А вот задействованные Gmu (родительский) иОбъекты Tag (дочерние):
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;
}
}
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;
}
}
Есть идеи?Я относительно новичок в Hibernate, но мне кажется, что я понимаю концепцию mappedby, и, опять же, она прекрасно работает при локальном запуске, но не развернута в Heroku.
Спасибо за понимание