Jdk 1.8.0_82、Springboot 1.3.8 和 JPA。
我想插入由现有对象值组成的新行。
我只是打电话
List<LogSchemaFieldModel> newFields = Lists.newArrayList();
for(LogSchemaFieldModel f : fields){
newFields.add(new LogSchemaFieldModel(){{
setFieldName( f.getFieldName() );
setFieldType( f.getFieldType() );
setFieldOpt( Field.Mode.NULLABLE.toString() );
setDescription( f.getDescription() );
setSampleValue( f.getSampleValue() );
setCommon(true);
setRequired(null);
}});
}
repo.save(newFields);
Run Code Online (Sandbox Code Playgroud)
但它抛出了这个异常。
org.springframework.dao.InvalidDataAccessApiUsageException: Unknown entity: com......service.LogDefineService$6; nested exception is java.lang.IllegalArgumentException: Unknown entity: com......service.LogDefineService$6
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:384) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:227) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:436) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59) ~[spring-tx-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) ~[spring-tx-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147) ~[spring-tx-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:131) ~[spring-data-jpa-1.9.5.RELEASE.jar:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at …Run Code Online (Sandbox Code Playgroud)