在ServletContext资源中定义名为'entityManagerFactory'的bean时出错

时间:2015-01-14 09:43:04

标签: java spring hibernate

我正在使用ecplise构建一个Web Applikation。我正在使用Spring和Hibernate。它工作正常,直到我添加了一个包含额外列的关系表的多对多关系。

堆栈跟踪:

161  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
5417 [main] INFO  org.springframework.web.context.support.XmlWebApplicationContext  - Bean 'myExecutor' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
5435 [main] INFO  org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor  - Initializing ExecutorService 
5435 [main] INFO  org.springframework.web.context.support.XmlWebApplicationContext  - Bean 'myExecutor' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
5498 [main] INFO  org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler  - Initializing ExecutorService  'myScheduler'
5500 [main] INFO  org.springframework.web.context.support.XmlWebApplicationContext  - Bean 'myScheduler' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
5536 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory  - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1484fc8d: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,compncompanyDAO,comptcompanyTypeDAO,contycountryDAO,curcycurrencyDAO,descpdescriptionDAO,descpexpfilesDAO,descpexploitationDAO,descpexpnatureDAO,descpexpstatusDAO,descpforegroundDAO,descriptionpropertyDAO,descriptiontypeDAO,fdatyfundingauthorityDAO,foregrpropertyDAO,perfnpersonalfunctionDAO,perslpersonalDAO,phasphaseDTO,planplanDAO,prgrmprogramDAO,projtprojectDAO,propdatatypesDAO,proppropertiesDAO,ptypepartnertypeDAO,ptypeplantypeDAO,relatallpropDAO,relatcompnprojtDAO,relatdescriptionpropertyDAO,relatexpfilesDAO,relatexpnatureDAO,relatfdatypropDAO,relatforegrpropertyDAO,relatperslprojtDAO,relatplandescpDAO,relatplanpropDAO,relatprgrmpropDAO,relatprojtdescpDAO,relatprojtforegrDAO,relatprojtpropDAO,statustatusDAO,reproshipService,org.springframework.scheduling.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.internalScheduledAnnotationProcessor,myExecutor,myScheduler,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,entityManagerFactory,transactionManager]; root of factory hierarchy
5620 [main] INFO  org.springframework.orm.jpa.LocalEntityManagerFactoryBean  - Building JPA EntityManagerFactory for persistence unit 'MyPersistenceUnit'
5713 [main] INFO  org.hibernate.cfg.annotations.Version  - Hibernate Annotations 3.5.2-Final
5734 [main] INFO  org.hibernate.cfg.Environment  - Hibernate 3.5.2-Final
5736 [main] INFO  org.hibernate.cfg.Environment  - hibernate.properties not found
5741 [main] INFO  org.hibernate.cfg.Environment  - Bytecode provider name : javassist
5747 [main] INFO  org.hibernate.cfg.Environment  - using JDK 1.4 java.sql.Timestamp handling
6216 [main] INFO  org.hibernate.annotations.common.Version  - Hibernate Commons Annotations 3.2.0.Final
6225 [main] INFO  org.hibernate.ejb.Version  - Hibernate EntityManager 3.5.2-Final
6875 [main] INFO  org.hibernate.cfg.AnnotationBinder  - Binding entity from annotated class: de.cmt.reproship.shared.dto.PtypePartnerTypeDTO
6921 [main] INFO  org.hibernate.cfg.annotations.EntityBinder  - Bind entity de.cmt.reproship.shared.dto.PtypePartnerTypeDTO on table ptype_partner_type
6973 [main] INFO  org.hibernate.cfg.AnnotationBinder  - Binding entity from annotated class: de.cmt.reproship.shared.dto.PrgrmProgramDTO
6973 [main] INFO  org.hibernate.cfg.annotations.EntityBinder  - Bind entity de.cmt.reproship.shared.dto.PrgrmProgramDTO on table prgrm_program
6988 [main] INFO  org.hibernate.cfg.AnnotationBinder  - Binding entity from annotated class: de.cmt.reproship.shared.dto.DescpForegroundDTO
6989 [main] INFO  org.hibernate.cfg.annotations.EntityBinder  - Bind entity de.cmt.reproship.shared.dto.DescpForegroundDTO on table descp_foreground
6991 [main] INFO  org.hibernate.cfg.AnnotationBinder  - Binding entity from annotated class: de.cmt.reproship.shared.dto.DescpDescriptionDTO

7025 [main] INFO  org.hibernate.cfg.AnnotationBinder  - Binding entity from annotated class: de.cmt.reproship.shared.dto.ContyCountryDTO
7026 [main] INFO  org.hibernate.cfg.annotations.EntityBinder  - Bind entity de.cmt.reproship.shared.dto.ContyCountryDTO on table conty_country
7030 [main] INFO  org.hibernate.cfg.AnnotationBinder  - Binding entity from annotated class: de.cmt.reproship.shared.dto.RelatPlanPropDTO
  7315 [main] INFO  org.hibernate.cfg.AnnotationConfiguration  - Hibernate Validator not found: ignoring
7357 [main] INFO  org.hibernate.validator.util.Version  - Hibernate Validator 4.2.0.Final
7641 [main] INFO  org.hibernate.search.Version  - Hibernate Search 3.4.0.Final
7760 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory  - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1484fc8d: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,compncompanyDAO,comptcompanyTypeDAO,contycountryDAO,curcycurrencyDAO,descpdescriptionDAO,descpexpfilesDAO,descpexploitationDAO,descpexpnatureDAO,descpexpstatusDAO,descpforegroundDAO,descriptionpropertyDAO,descriptiontypeDAO,fdatyfundingauthorityDAO,foregrpropertyDAO,perfnpersonalfunctionDAO,perslpersonalDAO,phasphaseDTO,planplanDAO,prgrmprogramDAO,projtprojectDAO,propdatatypesDAO,proppropertiesDAO,ptypepartnertypeDAO,ptypeplantypeDAO,relatallpropDAO,relatcompnprojtDAO,relatdescriptionpropertyDAO,relatexpfilesDAO,relatexpnatureDAO,relatfdatypropDAO,relatforegrpropertyDAO,relatperslprojtDAO,relatplandescpDAO,relatplanpropDAO,relatprgrmpropDAO,relatprojtdescpDAO,relatprojtforegrDAO,relatprojtpropDAO,statustatusDAO,reproshipService,org.springframework.scheduling.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.internalScheduledAnnotationProcessor,myExecutor,myScheduler,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,entityManagerFactory,transactionManager]; root of factory hierarchy
7769 [main] INFO  org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler  - Shutting down ExecutorService 'myScheduler'
7771 [main] ERROR org.springframework.web.context.ContextLoader  - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'compncompanyDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: javax.persistence.EntityManagerFactory de.cmt.reproship.server.dao.CompnCompanyDAO.entityManagerFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: MyPersistenceUnit] Unable to build EntityManagerFactory
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1055)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:543)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
    at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:468)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:222)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1093)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:836)
    at com.google.gwt.dev.DevMode.main(DevMode.java:311)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: javax.persistence.EntityManagerFactory de.cmt.reproship.server.dao.CompnCompanyDAO.entityManagerFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: MyPersistenceUnit] Unable to build EntityManagerFactory
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:507)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
    ... 31 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: MyPersistenceUnit] Unable to build EntityManagerFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1403)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:825)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:767)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:685)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
    ... 33 more
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: MyPersistenceUnit] Unable to build EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:896)
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
    at org.springframework.orm.jpa.LocalEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalEntityManagerFactoryBean.java:92)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)
    ... 43 more
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: descp_exploitation, for columns: [org.hibernate.mapping.Column(relexpnature)]
    at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:291)

感谢您的帮助!

我的课程:

package de.cmt.reproship.shared.dto;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinColumn;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Table;


@Entity
@Table(name = "descp_exploitation")
public class DescpExploitationDTO implements Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = -356131095078296285L;

    public DescpExploitationDTO(){
    }

    public DescpExploitationDTO(long expID, long relcpID, long projtID, long statuID, long foregrID, String expcomment, String expplans, String expactualexp, String expsourcestatusinfo, String descpexploitationcol, ProjtProjectDTO project) {

        this.expID = expID;
        this.relcpID = relcpID;
        this.projtID = projtID;
        this.statuID = statuID;
        this.foregrID = foregrID;
        this.expcomment = expcomment;
        this.expplans = expplans;
        this.expactualexp = expactualexp;
        this.expsourcestatusinfo = expsourcestatusinfo;
        this.descpexploitationcol = descpexploitationcol;
        this.project = project;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "exp_ID")
    private long expID;

    @Column(name = "relcp_ID", nullable = false, length = 30)
    private long relcpID;   

    @Column(name = "projt_ID", nullable = false, length = 30)
    private long projtID;   

    @Column(name = "statu_ID", nullable = false, length = 30)
    private long statuID;

    @Column(name = "foregr_ID", nullable = false, length = 30)
    private long foregrID;  

    @Column(name = "exp_comment", nullable = true, length = 50)
    private String expcomment;

    @Column(name = "exp_expplans", nullable = true, length = 8000)
    private String expplans;

    @Column(name = "exp_actualexp", nullable = true, length = 8000)
    private String expactualexp;

    @Column(name = "exp_sourcestatusinfo", nullable = true, length = 8000)
    private String expsourcestatusinfo;

    @Column(name = "descp_exploitationcol", nullable = true, length = 50)
    private String descpexploitationcol;

    @ManyToOne
    @JoinColumn(name="projt_ID", insertable =false, updatable =false)
    private ProjtProjectDTO project;

    private Set<RelatExpNatureDTO> relexpnature = new HashSet<RelatExpNatureDTO>(0);


    public long getExpID() {
        return expID;
    }

    public void setExpID(long expID) {
        this.expID = expID;
    }

    public long getRelcpID() {
        return relcpID;
    }

    public void setRelcpID(long relcpID) {
        this.relcpID = relcpID;
    }

    public long getProjtID() {
        return projtID;
    }

    public void setProjtID(long projtID) {
        this.projtID = projtID;
    }

    public long getStatuID() {
        return statuID;
    }

    public void setStatuID(long statuID) {
        this.statuID = statuID;
    }

    public long getForegrID() {
        return foregrID;
    }

    public void setForegrID(long foregrID) {
        this.foregrID = foregrID;
    }

    public String getExpcomment() {
        return expcomment;
    }

    public void setExpcomment(String expcomment) {
        this.expcomment = expcomment;
    }

    public String getExpplans() {
        return expplans;
    }

    public void setExpplans(String expplans) {
        this.expplans = expplans;
    }

    public String getExpactualexp() {
        return expactualexp;
    }

    public void setExpactualexp(String expactualexp) {
        this.expactualexp = expactualexp;
    }

    public String getExpsourcestatusinfo() {
        return expsourcestatusinfo;
    }

    public void setExpsourcestausinfo(String expsourcestatusinfo) {
        this.expsourcestatusinfo = expsourcestatusinfo;
    }

    public String getDescpexploitationcol() {
        return descpexploitationcol;
    }

    public void setDescpexploitationcol(String descpexploitationcol) {
        this.descpexploitationcol = descpexploitationcol;
    }

    public ProjtProjectDTO getProject() {
        return project;
    }

    public void setProject(ProjtProjectDTO project) {
        this.project = project;
    }

    @OneToMany(fetch=FetchType.LAZY, mappedBy = "pk.descpexploitationdto", cascade = CascadeType.ALL)
    public Set<RelatExpNatureDTO> getRelexpnature() {
        return relexpnature;
    }

    public void setRelexpnature(Set<RelatExpNatureDTO> relexpnature) {
        this.relexpnature = relexpnature;
    }


}





  package de.cmt.reproship.shared.dto;

    import static javax.persistence.GenerationType.IDENTITY;

    import java.io.Serializable;
    import java.util.HashSet;
    import java.util.Set;

    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Id;
    import javax.persistence.ManyToMany;
    import javax.persistence.OneToMany;
    import javax.persistence.Table;

    @Entity
    @Table(name = "descp_exp_nature")
    public class DescpExpNatureDTO implements Serializable{

        /**
         * 
         */
        private static final long serialVersionUID = -4753028274220167848L;

        public DescpExpNatureDTO(){
        }

        public DescpExpNatureDTO(long expnatureID, String expnaturename){
            this.expnatureID = expnatureID;
            this.expnaturename = expnaturename;
        }

        @Id
        @GeneratedValue(strategy = IDENTITY)
        @Column(name = "nature_ID")
        private long expnatureID;

        @Column(name = "exp_nature_name", nullable = true, length = 150)
        private String expnaturename;

        private Set<RelatExpNatureDTO> relexpnature = new HashSet<RelatExpNatureDTO>(0);



        public long getExpnatureID() {
            return expnatureID;
        }

        public void setExpnatureID(long expnatureID) {
            this.expnatureID = expnatureID;
        }

        public String getExpnaturename() {
            return expnaturename;
        }

        public void setExpnaturename(String expnaturename) {
            this.expnaturename = expnaturename;
        }

        @OneToMany(fetch=FetchType.LAZY, mappedBy = "pk.descpexpnaturedto", cascade = CascadeType.ALL)
        public Set<RelatExpNatureDTO> getRelexpnature() {
            return relexpnature;
        }

        public void setRelexpnature(Set<RelatExpNatureDTO> relexpnature) {
            this.relexpnature = relexpnature;
        }

    }


    }


package de.cmt.reproship.shared.dto;

import java.io.Serializable;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "relat_exp_nature")
@AssociationOverrides({
    @AssociationOverride(name = "pk.descpexploitationdto", 
        joinColumns = @JoinColumn(name = "exp_ID")),
    @AssociationOverride(name = "pk.descpexpnaturedto", 
        joinColumns = @JoinColumn(name = "nature_ID")) })
public class RelatExpNatureDTO implements Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = -6588800263746481041L;

    private ExpNatureId pk = new ExpNatureId();


    @Column(name = "relcp_ID", nullable = false, length = 20)
    private long relcpID;

    @Column(name = "projt_ID", nullable = false, length = 20)
    private long projtID;


    @ManyToOne
    @JoinColumn(name="exp_ID", insertable =false, updatable =false)
    private DescpExploitationDTO exploitations;

    @ManyToOne
    @JoinColumn(name="nature_ID", insertable =false, updatable =false)
    private DescpExpNatureDTO nature;

    public RelatExpNatureDTO(){

    }

    @EmbeddedId
    public ExpNatureId getPk() {
        return pk;
    }

    public void setPk(ExpNatureId pk) {
        this.pk = pk;
    }

    @Transient
    public DescpExploitationDTO getDescpExploitationDTO() {
        return getPk().getDescpExploitationDTO();
    }

    public void setDescpExploitationDTO(DescpExploitationDTO exploitation) {
        getPk().setDescpExploitationDTO(exploitation);
    }

    @Transient
    public DescpExpNatureDTO getDescpExpNatureDTO() {
        return getPk().getDescpExpNatureDTO();
    }

    public void setDescpExpNatureDTO(DescpExpNatureDTO expnature) {
        getPk().setDescpExpNatureDTO(expnature);
    }


    public long getRelcpID() {
        return relcpID;
    }

    public void setRelcpID(long relcpID) {
        this.relcpID = relcpID;
    }

    public long getProjtID() {
        return projtID;
    }

    public void setProjtID(long projtID) {
        this.projtID = projtID;
    }

    public DescpExploitationDTO getExploitations() {
        return exploitations;
    }

    public void setExploitations(DescpExploitationDTO exploitations) {
        this.exploitations = exploitations;
    }

    public DescpExpNatureDTO getNature() {
        return nature;
    }

    public void setNature(DescpExpNatureDTO nature) {
        this.nature = nature;
    }


    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;

        RelatExpNatureDTO that = (RelatExpNatureDTO) o;

        if (getPk() != null ? !getPk().equals(that.getPk())
                : that.getPk() != null)
            return false;

        return true;
    }


    public int hashCode() {
        return (getPk() != null ? getPk().hashCode() : 0);
    }

}

package de.cmt.reproship.shared.dto;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class ExpNatureId implements Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = 1750980964547512826L;

    private DescpExploitationDTO exploitation;
    private DescpExpNatureDTO expnature;

    public ExpNatureId(){

    }

    @ManyToOne
    public DescpExploitationDTO getDescpExploitationDTO() {
        return exploitation;
    }

    public void setDescpExploitationDTO(DescpExploitationDTO exploitation) {
        this.exploitation = exploitation;
    }

    @ManyToOne
    public DescpExpNatureDTO getDescpExpNatureDTO() {
        return expnature;
    }

    public void setDescpExpNatureDTO(DescpExpNatureDTO expnature) {
        this.expnature = expnature;
    }


    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ExpNatureId that = (ExpNatureId) o;

        if (exploitation != null ? !exploitation.equals(that.exploitation) : that.exploitation != null) return false;
        if (expnature != null ? !expnature.equals(that.expnature) : that.expnature != null)
            return false;

        return true;
    }


    public int hashCode() {
        int result;
        result = (exploitation != null ? exploitation.hashCode() : 0);
        result = 31 * result + (expnature != null ? expnature.hashCode() : 0);
        return result;
    }

}

我的compncompanyDAO课程:

package de.cmt.reproship.server.dao;

import javax.annotation.PostConstruct;
import javax.persistence.EntityManagerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import de.cmt.reproship.shared.dto.CompnCompanyDTO;

@Repository("compncompanyDAO")
public class CompnCompanyDAO extends JpaDAO<Long, CompnCompanyDTO> {

    @Autowired
    EntityManagerFactory entityManagerFactory;

    @PostConstruct
    public void init() {
        super.setEntityManagerFactory(entityManagerFactory);
    }
}

1 个答案:

答案 0 :(得分:0)

相关问题