简体   繁体   中英

Spring MVC + Hibernate : BeanCreationException error after regenerating model classes

I have a Spring MVC + Hibernate application that has been working perfectly for a while : my model classes have been generated by Hibernate from my MySQL databese.

I made DAO objects and services for interactions between the application and the database. Everything was working fine.

Today I updated the "Site" table of my database. When I re-generated the classes of the model with Hibernate, problems arrived.

Since, I get the org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig' when I try to start my Tomcat Server.

What did I miss ? Here are my AppConfig class and the Site.java class that has been generated. If I replace it by the previous one, everything works fine again.

EDIT

mai 15, 2017 3:50:44 PM org.springframework.web.context.support.AnnotationConfigWebApplicationContext refresh
AVERTISSEMENT: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.converter.RoleToUserProfileConverter com.sggsmi.bending.configuration.AppConfig.roleToUserProfileConverter; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleToUserProfileConverter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.service.UserProfileService com.sggsmi.bending.converter.RoleToUserProfileConverter.userProfileService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.dao.UserProfileDao com.sggsmi.bending.service.UserProfileServiceImpl.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.sggsmi.bending.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/sggsmi/bending/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.sggsmi.bending.model.Machine.setups in com.sggsmi.bending.model.Setup.machines
mai 15, 2017 3:50:44 PM org.springframework.web.context.ContextLoader initWebApplicationContext
GRAVE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.converter.RoleToUserProfileConverter com.sggsmi.bending.configuration.AppConfig.roleToUserProfileConverter; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleToUserProfileConverter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.service.UserProfileService com.sggsmi.bending.converter.RoleToUserProfileConverter.userProfileService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.dao.UserProfileDao com.sggsmi.bending.service.UserProfileServiceImpl.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.sggsmi.bending.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/sggsmi/bending/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.sggsmi.bending.model.Machine.setups in com.sggsmi.bending.model.Setup.machines
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:697)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:526)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4730)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5194)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1406)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.converter.RoleToUserProfileConverter com.sggsmi.bending.configuration.AppConfig.roleToUserProfileConverter; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleToUserProfileConverter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.service.UserProfileService com.sggsmi.bending.converter.RoleToUserProfileConverter.userProfileService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.dao.UserProfileDao com.sggsmi.bending.service.UserProfileServiceImpl.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.sggsmi.bending.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/sggsmi/bending/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.sggsmi.bending.model.Machine.setups in com.sggsmi.bending.model.Setup.machines
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleToUserProfileConverter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.service.UserProfileService com.sggsmi.bending.converter.RoleToUserProfileConverter.userProfileService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.dao.UserProfileDao com.sggsmi.bending.service.UserProfileServiceImpl.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.sggsmi.bending.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/sggsmi/bending/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.sggsmi.bending.model.Machine.setups in com.sggsmi.bending.model.Setup.machines
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
    ... 32 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.service.UserProfileService com.sggsmi.bending.converter.RoleToUserProfileConverter.userProfileService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.dao.UserProfileDao com.sggsmi.bending.service.UserProfileServiceImpl.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.sggsmi.bending.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/sggsmi/bending/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.sggsmi.bending.model.Machine.setups in com.sggsmi.bending.model.Setup.machines
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    ... 43 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.dao.UserProfileDao com.sggsmi.bending.service.UserProfileServiceImpl.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.sggsmi.bending.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/sggsmi/bending/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.sggsmi.bending.model.Machine.setups in com.sggsmi.bending.model.Setup.machines
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
    ... 45 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sggsmi.bending.dao.UserProfileDao com.sggsmi.bending.service.UserProfileServiceImpl.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.sggsmi.bending.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/sggsmi/bending/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.sggsmi.bending.model.Machine.setups in com.sggsmi.bending.model.Setup.machines
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    ... 56 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userProfileDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.sggsmi.bending.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/sggsmi/bending/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.sggsmi.bending.model.Machine.setups in com.sggsmi.bending.model.Setup.machines
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
    ... 58 more

EDIT 2

Machine.java

package com.sggsmi.bending.model;
// Generated 15 mai 2017 16:18:03 by Hibernate Tools 5.1.0.Beta1

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * Machine generated by hbm2java
 */
@Entity
@Table(name = "machine", catalog = "bec")
public class Machine implements java.io.Serializable {

    private int machineId;
    private Site site;
    private String machineName;

    public Machine() {
    }

    public Machine(int machineId, Site site, String machineName) {
        this.machineId = machineId;
        this.site = site;
        this.machineName = machineName;
    }

    @Id

    @Column(name = "machineId", unique = true, nullable = false)
    public int getMachineId() {
        return this.machineId;
    }

    public void setMachineId(int machineId) {
        this.machineId = machineId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "siteId", nullable = false)
    public Site getSite() {
        return this.site;
    }

    public void setSite(Site site) {
        this.site = site;
    }

    @Column(name = "machineName", nullable = false, length = 50)
    public String getMachineName() {
        return this.machineName;
    }

    public void setMachineName(String machineName) {
        this.machineName = machineName;
    }

}

Setup.java

package com.sggsmi.bending.model;
// Generated 24 mars 2017 17:13:20 by Hibernate Tools 5.1.0.Beta1

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * Setup generated by hbm2java
 */
@Entity
@Table(name = "setup", catalog = "bec")
public class Setup implements java.io.Serializable {

    private int setupId;
    private boolean pbi;
    private boolean shape;
    private float widthMin;
    private float widthMax;
    private float heightMin;
    private float heightMax;
    private int retrait;
    private Set<Machine> machines = new HashSet<Machine>(0);
    private Set<Articles> articleses = new HashSet<Articles>(0);

    public Setup() {
    }

    public Setup(int setupId, boolean pbi, boolean shape, float widthMin, float widthMax, float heightMin,
            float heightMax, int retrait) {
        this.setupId = setupId;
        this.pbi = pbi;
        this.shape = shape;
        this.widthMin = widthMin;
        this.widthMax = widthMax;
        this.heightMin = heightMin;
        this.heightMax = heightMax;
        this.retrait = retrait;
    }

    public Setup(int setupId, boolean pbi, boolean shape, float widthMin, float widthMax, float heightMin,
            float heightMax, int retrait, Set<Machine> machines, Set<Articles> articleses) {
        this.setupId = setupId;
        this.pbi = pbi;
        this.shape = shape;
        this.widthMin = widthMin;
        this.widthMax = widthMax;
        this.heightMin = heightMin;
        this.heightMax = heightMax;
        this.retrait = retrait;
        this.machines = machines;
        this.articleses = articleses;
    }

    @Id

    @Column(name = "setupId", unique = true, nullable = false)
    public int getSetupId() {
        return this.setupId;
    }

    public void setSetupId(int setupId) {
        this.setupId = setupId;
    }

    @Column(name = "pbi", nullable = false)
    public boolean isPbi() {
        return this.pbi;
    }

    public void setPbi(boolean pbi) {
        this.pbi = pbi;
    }

    @Column(name = "shape", nullable = false)
    public boolean isShape() {
        return this.shape;
    }

    public void setShape(boolean shape) {
        this.shape = shape;
    }

    @Column(name = "widthMin", nullable = false, precision = 12, scale = 0)
    public float getWidthMin() {
        return this.widthMin;
    }

    public void setWidthMin(float widthMin) {
        this.widthMin = widthMin;
    }

    @Column(name = "widthMax", nullable = false, precision = 12, scale = 0)
    public float getWidthMax() {
        return this.widthMax;
    }

    public void setWidthMax(float widthMax) {
        this.widthMax = widthMax;
    }

    @Column(name = "heightMin", nullable = false, precision = 12, scale = 0)
    public float getHeightMin() {
        return this.heightMin;
    }

    public void setHeightMin(float heightMin) {
        this.heightMin = heightMin;
    }

    @Column(name = "heightMax", nullable = false, precision = 12, scale = 0)
    public float getHeightMax() {
        return this.heightMax;
    }

    public void setHeightMax(float heightMax) {
        this.heightMax = heightMax;
    }

    @Column(name = "retrait", nullable = false)
    public int getRetrait() {
        return this.retrait;
    }

    public void setRetrait(int retrait) {
        this.retrait = retrait;
    }

    @ManyToMany(fetch = FetchType.LAZY, mappedBy = "setups")
    public Set<Machine> getMachines() {
        return this.machines;
    }

    public void setMachines(Set<Machine> machines) {
        this.machines = machines;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "setuparticle", catalog = "bec", joinColumns = {
            @JoinColumn(name = "setupId", nullable = false, updatable = false) }, inverseJoinColumns = {
                    @JoinColumn(name = "artId", nullable = false, updatable = false) })
    public Set<Articles> getArticleses() {
        return this.articleses;
    }

    public void setArticleses(Set<Articles> articleses) {
        this.articleses = articleses;
    }

}

It appears the relationship between Setup and Machine is what is causing your issue.

This error typically happens when one entity is included in the mapping configuration and the other entity is not or when the mappedBy attribute of the annotation points to an incorrectly named property in the referenced target entity class.

From the trace mappedBy reference an unknown target entity property: com.sggsmi.bending.model.Machine.setups in com.sggsmi.bending.model.Setup.machines. It's something wrong with your Entities referenced to unknown, not mapped property

You have in the Setup entity

@ManyToMany(fetch = FetchType.LAZY, mappedBy = "setups")
public Set<Machine> getMachines() {
    return this.machines;
}

But there is no setups in the Machine.

They linked as ManyToMany so you need to point relations table Machine_Setup (don't know how it's actually called in your DB)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM