问题描述
关系是这样的 enter image description here
我的超类(用户)是这样的,在这里我用@OnetoMany 发送与我的子类(雇主)的关系 enter image description here
我的子类(雇主)就是这样,在这里我与超类(用户)的@ManyToOne 建立了关系。 enter image description here
并且我使用 Dto 将我在数据库中关联的表保存在一个类中。 enter image description here
我创建了一个数据访问对象 (DAO) 来将我的数据传输到 Dto 类中的字段,并编写了一个这样的查询。 enter image description here
但是它给了我一个 id 错误,因为我已经从 User 类中提取了雇主类的 id。
2021-06-02 01:32:59.651 INFO 11760 --- [ restartedMain] kodlamaio.hrms.HrmsApplication : No active profile set,falling back to default profiles: default
2021-06-02 01:32:59.712 INFO 11760 --- [ restartedMain] o.s.b.devtools.restart.Changeableurls : The Class-Path manifest attribute in D:\web-developeer files\mail.jar referenced one or more files that do not exist: file:/D:/web-developeer%20files/activation.jar
2021-06-02 01:32:59.713 INFO 11760 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2021-06-02 01:32:59.713 INFO 11760 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2021-06-02 01:33:00.596 INFO 11760 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-06-02 01:33:00.650 INFO 11760 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 44 ms. Found 1 JPA repository interfaces.
2021-06-02 01:33:01.216 INFO 11760 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8090 (http)
2021-06-02 01:33:01.228 INFO 11760 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-06-02 01:33:01.229 INFO 11760 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.45]
2021-06-02 01:33:01.372 INFO 11760 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-06-02 01:33:01.372 INFO 11760 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1658 ms
2021-06-02 01:33:01.519 INFO 11760 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-06-02 01:33:01.573 INFO 11760 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.30.Final
2021-06-02 01:33:01.704 INFO 11760 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-06-02 01:33:01.818 INFO 11760 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-06-02 01:33:02.014 INFO 11760 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-06-02 01:33:02.034 INFO 11760 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgresqlDialect
2021-06-02 01:33:03.614 INFO 11760 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-06-02 01:33:03.623 INFO 11760 --- [ restartedMain] j.LocalContainerEntityManagerfactorybean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-06-02 01:33:03.657 INFO 11760 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2021-06-02 01:33:03.841 WARN 11760 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore,database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-06-02 01:33:03.986 INFO 11760 --- [ restartedMain] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String,HttpServletRequest)]
2021-06-02 01:33:04.079 INFO 11760 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-06-02 01:33:04.416 WARN 11760 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employerDao' defined in kodlamaio.hrms.dataAccess.abstracts.EmployerDao defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method Failed; nested exception is java.lang.IllegalArgumentException: This class [class kodlamaio.hrms.entities.Employer] does not define an IdClass
2021-06-02 01:33:04.416 INFO 11760 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2021-06-02 01:33:04.418 INFO 11760 --- [ restartedMain] j.LocalContainerEntityManagerfactorybean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-06-02 01:33:04.423 INFO 11760 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-06-02 01:33:04.427 INFO 11760 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2021-06-02 01:33:04.430 INFO 11760 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)