Issue
I'm new using this framework, I'm tryng to deploy a web with a hibernate connection, I created a .xml config file to connect to PostgreSQL.
But the logs shows this error:
2020-11-14T22:32:28.610246+00:00 heroku[router]: at=info method=GET path="/"
host=gstlabs.herokuapp.com request_id=978ecfdc-917f-41a0-8867-8cc55b73def1 fwd="190.84.149.124" dyno=web.1 connect=2ms service=211ms status=500 bytes=610 protocol=https
2020-11-14T23:04:34.213061+00:00 heroku[web.1]: Idling
2020-11-14T23:04:34.215664+00:00 heroku[web.1]: State changed from up to down
2020-11-14T23:04:35.167671+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-11-14T23:04:35.279279+00:00 app[web.1]: 2020-11-14 23:04:35.278 INFO 4 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-11-14T23:04:35.279712+00:00 app[web.1]: 2020-11-14 23:04:35.279 WARN 4 --- [extShutdownHook] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'entityManagerFactory': org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.example.core.models.Projects.technologies in com.example.core.models.Technologies.projects
2020-11-14T23:04:35.280073+00:00 app[web.1]: 2020-11-14 23:04:35.279 INFO 4 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-11-14T23:04:35.282600+00:00 app[web.1]: 2020-11-14 23:04:35.282 INFO 4 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-11-14T23:04:35.325392+00:00 app[web.1]: 2020-11-14 23:04:35.325 INFO 4 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-11-14T23:04:35.426750+00:00 heroku[web.1]: Process exited with status 143
There are my Classes: [Technologies]
package com.example.core.models;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
@Entity
@Table(name="technologies")
public class Technologies {
@Id
@Column(name="id")
private int id;
@Column(name="name")
private String name;
public Technologies() {
}
public Technologies(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Technologies [id=" + id + ", name=" + name + "]";
}
@ManyToMany(mappedBy="technologies")
private Set<Projects> projects = new HashSet<>();
public Set<Projects> getProjects() {
return projects;
}
public void setProjects(Set<Projects> projects) {
this.projects = projects;
}
}
[Projects]
package com.example.core.models;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
@Entity
@Table(name="projects")
public class Projects {
@Id
@Column(name="id")
private int id;
@Column(name="photo")
private String photo;
@Column(name="link")
private String link;
public Projects() {
}
public Projects(String photo, String link) {
this.photo = photo;
this.link = link;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
@Override
public String toString() {
return "Projects [id=" + id + ", photo=" + photo + ", link=" + link + "]";
}
@ManyToMany(cascade= {CascadeType.ALL})
@JoinTable(
name="projects_has_technologies",
joinColumns=@JoinColumn(name="project_id"),
inverseJoinColumns=@JoinColumn(name="technology_id")
)
Set<Technologies> tecnologies = new HashSet<>();
@ManyToMany(mappedBy="projects")
private Set<Profiles> profiles = new HashSet<>();
public Set<Technologies> getTecnologies() {
return tecnologies;
}
public void setTecnologies(Set<Technologies> tecnologies) {
this.tecnologies = tecnologies;
}
public Set<Profiles> getProfiles() {
return profiles;
}
public void setProfiles(Set<Profiles> profiles) {
this.profiles = profiles;
}
}
There are some code that are some at my clases in this proyect the other intermedial clases are similar, I'm trynt in this moment insert some objects to the database. Thanks to your help in advance.
Solution
Have you tried to add a Configuration Class in your project for example
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories( basePackages = "your repository package" )
@EntityScan( basePackages = {"your entity package1","your entity package2"}
public class TransactionConfiguration {}
This will help you to find your entity classes in the project.
Answered By - Sumana Saha
Answer Checked By - Mary Flores (JavaFixing Volunteer)