2016-09-30 2 views
0

Map Benutzertabelle für Update auf UserProfilePersonalInfo Tabelle die DatenWie wird ein POJO einem anderen POJO in Java zugeordnet?

Benutzer POJO Karte

@OneToOne(mappedBy = "users",cascade = CascadeType.ALL) 
private UserProfilePersonalInfo userProfilePersonalInfo; 

In UserProfilePersonalInfo POJO

@OneToOne 
@JoinColumn(name = "user_id") 
private User user; 

In Hibernate Konfiguration

@Bean 
public LocalSessionFactoryBean sessionFactory() { 
    LocalSessionFactoryBean sessionFactory = new 
    LocalSessionFactoryBean(); 
    sessionFactory.setDataSource(dataSource()); 
    sessionFactory.setPackagesToScan(new String[] { "com.a2z.model" }); 
    sessionFactory.setHibernateProperties(hibernateProperties()); 
    return sessionFactory; 
} 
private Properties hibernateProperties() { 
    Properties properties = new Properties(); 
    properties.put("hibernate.dialect", 
    environment.getRequiredProperty("hibernate.dialect")); 
    properties.put("hibernate.show_sql", 
    environment.getRequiredProperty("hibernate.show_sql")); 
    properties.put("hibernate.format_sql", 
    environment.getRequiredProperty("hibernate.format_sql")); 
    return properties;   
} 

Ich bin vor Fehler auf der Konsole

WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through field 'usersService': Error creating bean with name 'usersService': Unsatisfied dependency expressed through field 'userdao': Error creating bean with name 'usersDao': Unsatisfied dependency expressed through field 'sessionFactory': Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'usersDao': Unsatisfied dependency expressed through field 'sessionFactory': Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'usersService': Unsatisfied dependency expressed through field 'userdao': Error creating bean with name 'usersDao': Unsatisfied dependency expressed through field 'sessionFactory': Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'usersDao': Unsatisfied dependency expressed through field 'sessionFactory': Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users 
Sep 30, 2016 7:32:38 PM org.springframework.web.context.ContextLoader initWebApplicationContext 
SEVERE: Context initialization failed 
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through field 'usersService': Error creating bean with name 'usersService': Unsatisfied dependency expressed through field 'userdao': Error creating bean with name 'usersDao': Unsatisfied dependency expressed through field 'sessionFactory': Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'usersDao': Unsatisfied dependency expressed through field 'sessionFactory': Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'usersService': Unsatisfied dependency expressed through field 'userdao': Error creating bean with name 'usersDao': Unsatisfied dependency expressed through field 'sessionFactory': Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'usersDao': Unsatisfied dependency expressed through field 'sessionFactory': Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/a2z/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.a2z.model.User.userProfilePersonalInfo, referenced property unknown: com.a2z.model.UserProfilePersonalInfo.users 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569) 
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349) 
    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.preInstantiateSingletons(DefaultListableBeanFactory.java:775) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) 
    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:4718) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 

Antwort

0
mappedBy = "user" 

Hier ist der Java-Feldname, nicht die SGBD Feldnamen. Tipps: Verwenden Sie sgbd Feldname, wo das Wort Spalte in der @annotation

angezeigt wird