出于个人原因,对于同一个实体,我有多个存储库,其中我有多个需要的本机命名查询,我的第一个想法是将查询代码从一个实体移动到另一个存储库,这样当我想要编辑查询时,我会在存储库中找到它,而不是实体(以避免一个大的实体代码充满查询)。
所以我尝试了这个实现。
这是我的存储库:
@SqlResultSetMappings({ @SqlResultSetMapping(name = TypeProduitRepository.REPOSITORY_SELECT_MAPPING, columns = {
@ColumnResult(name = "code", type = Long.class), @ColumnResult(name = "description", type = String.class),
@ColumnResult(name = "valeur_decimal", type = Double.class),
@ColumnResult(name = "valeur_entier", type = Long.class),
@ColumnResult(name = "valeur_alpha_num", type = String.class) }) })
@NamedNativeQueries({
@NamedNativeQuery(
name = TypeProduitRepository.REPOSITORY + ".select",
query =
"SELECT "
+ "rp.parcin AS code,"
+ "rp.pardesc AS description, "
+ "rp.parvald AS valeur_decimal,"
+ "rp.parvall AS valeur_entier, "
+ "rp.parvals AS valeur_alpha_num\r\n"
+ "FROM ref_param rp\r\n"
+ "WHERE rp.partab = "+TypeProduitRepository.TABLE_CODE+" AND rp.donord = \"mds\";",
resultSetMapping = TypeProduitRepository.REPOSITORY_SELECT_MAPPING),
@NamedNativeQuery(
name = TypeProduitRepository.REPOSITORY + ".insert",
query =
"INSERT INTO `ref_param` "
+ "( `partab`, `derprg`, `deruser`, `donord`, `indicmaj`, `indtrans`, `pardesc`, `parvald`, `parvall`, `parvals`)"
+ " VALUES " + "( "+TypeProduitRepository.TABLE_CODE+", :derprg, :deruser, :donord, 0, 0, :pardesc, :parvald, :parvall, :parvals);"
+ "\r\n" + ""),
@NamedNativeQuery(
name = TypeProduitRepository.REPOSITORY + ".update",
query =
"UPDATE ref_param \r\n"
+ "SET \r\n"
+ " datmaj = NOW() -- datmaj - DATE NOT NULL\r\n"
+ " ,derprg = :derprg -- derprg - VARCHAR(13) NOT NULL\r\n"
+ " ,deruser = :deruser -- deruser - VARCHAR(13) NOT NULL\r\n"
+ " ,donord = :donord -- donord - VARCHAR(13) NOT NULL\r\n"
+ " ,indicmaj = indicmaj+1 -- indicmaj - BIGINT(20)\r\n"
+ " ,pardesc = :pardesc -- pardesc - VARCHAR(255) NOT NULL\r\n"
+ " ,parvald = :parvald -- parvald - DOUBLE\r\n"
+ " ,parvall = :parvall -- parvall - BIGINT(20)\r\n"
+ " ,parvals = :parvals -- parvals - VARCHAR(255)\r\n"
+ "WHERE\r\n"
+ " parcin = :parcin -- parcin - BIGINT(20) NOT NULL\r\n"
+ " AND partab = "+TypeProduitRepository.TABLE_CODE+" -- partab - BIGINT(20) NOT NULL\r\n ;" ),
@NamedNativeQuery(
name = TypeProduitRepository.REPOSITORY + ".incerementInd",
query =
"UPDATE ref_param \r\n"
+ "SET \r\n"
+ " indtrans = indtrans+1 -- datmaj - DATE NOT NULL\r\n"
+ "WHERE\r\n"
+ " parcin = :parcin -- parcin - BIGINT(20) NOT NULL\r\n"
+ " AND partab = "+TypeProduitRepository.TABLE_CODE+" -- partab - BIGINT(20) NOT NULL\r\n ;" ),
@NamedNativeQuery(
name =TypeProduitRepository.REPOSITORY + ".delete",
query=
"DELETE FROM pos_auth.ref_param\r\n" +
"WHERE\r\n" +
" parcin = :parcin -- parcin - BIGINT(20) NOT NULL\r\n" +
" AND partab = "+TypeProduitRepository.TABLE_CODE+" -- partab - BIGINT(20) NOT NULL"
)
})
@Repository
public interface TypeProduitRepository extends JpaRepository<ReferencielParamettre, ReferencielParamettreID> {
public static final String REPOSITORY = "ReferencielParamettre.TypeProduitRepository";
public static final String REPOSITORY_SELECT_MAPPING = "ReferencielParamettre.TypeProduit";
public static final String TABLE_CODE = "1004";
@Query(name =REPOSITORY+".select" ,nativeQuery = true)
public List<TypeProduit> select();
@Transactional
@Modifying
@Query(name =REPOSITORY+".insert" ,nativeQuery = true)
public int insert( String derprg, String deruser, String donord, String pardesc, Double parvald, Long parvall, String parvals);
@Transactional
@Modifying
@Query(name =REPOSITORY+".update" ,nativeQuery = true)
public int update(Long parcin, String derprg, String deruser, String donord, String pardesc, Double parvald, Long parvall, String parvals);
@Transactional
@Modifying
@Query(name =REPOSITORY+".incerementInd" ,nativeQuery = true)
public int incerementInd(Long parcin);
@Transactional
@Modifying
@Query(name =REPOSITORY+".delete" ,nativeQuery = true)
public int delete(Long parcin);
}
接下来是我的实体:
@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "REF_PARAM")
@IdClass(ReferencielParamettreID.class)
@Check(constraints = "PARVALS IS NOT NULL OR PARVALD IS NOT NULL OR PARVALL IS NOT NULL ")
public class ReferencielParamettre extends CommonData implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7744229498316267737L;
/**
* partab Number code interne table parametre X N 1080 table de unite de mesure
*/
@Id
private Long partab;
/**
* parcin Number code interne parametre X N code 1 pour CM
*/
@Id
private Long parcin;
/**
* pardesc Varchar description du parametre X N par exemple : cm, centimetre
* affichage
*/
@Column(nullable = false)
private String pardesc;
/**
* parvall Number valeur entiere du parametre X Y par exemple coeficiant dual en
* mode affichage devrai avoir la valeur 2
*/
@Column(nullable = true)
private Long parvall;
/**
* parvald Number(5.2) valeur flotante du parametre X N par exemple Pi en
* affichage vaux 3.14
*/
@Column(nullable = true)
private Double parvald;
/**
* parvals VARCHAR valeur charactere du parametre X N par exemple pme vaux
* petite moyenne entreprise: possible utile dans l'impression d'une facture
*/
@Column(nullable = true)
private String parvals;
}
启动时,我确实会遇到以下异常:
org.springframework.beans.factory.BeanCreation异常:创建名为'typeProduitRepository'的bean时出错:初始化方法调用失败;嵌套异常java.lang.IllegalArgument异常:未能为方法公共抽象intmds.ref.common.repository.TypeProduitRepository.update创建查询(java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Douple,java.lang.Long,java.lang.String)!没有找到类型为ReanccielParamettre的属性更新!
以下是完整的堆栈跟踪:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'typeProduitRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract int mds.ref.common.repository.TypeProduitRepository.update(java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Double,java.lang.Long,java.lang.String)! No property update found for type ReferencielParamettre!
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at mds.ResourceApplication.main(ResourceApplication.java:28) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.1.RELEASE.jar:2.0.1.RELEASE]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'typeProduitRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract int mds.ref.common.repository.TypeProduitRepository.update(java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Double,java.lang.Long,java.lang.String)! No property update found for type ReferencielParamettre!
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
... 23 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'typeProduitRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract int mds.ref.common.repository.TypeProduitRepository.update(java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Double,java.lang.Long,java.lang.String)! No property update found for type ReferencielParamettre!
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:392) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:364) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$2afbee97.mvcConversionService(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.getConfigurableWebBindingInitializer(WebMvcConfigurationSupport.java:604) ~[spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration.getConfigurableWebBindingInitializer(WebMvcAutoConfiguration.java:524) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.requestMappingHandlerAdapter(WebMvcConfigurationSupport.java:566) ~[spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration.requestMappingHandlerAdapter(WebMvcAutoConfiguration.java:467) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$2afbee97.CGLIB$requestMappingHandlerAdapter$6(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$2afbee97$$FastClassBySpringCGLIB$$1ba8ac87.invoke(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$2afbee97.requestMappingHandlerAdapter(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
... 24 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'typeProduitRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract int mds.ref.common.repository.TypeProduitRepository.update(java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Double,java.lang.Long,java.lang.String)! No property update found for type ReferencielParamettre!
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
... 49 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'typeProduitRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract int mds.ref.common.repository.TypeProduitRepository.update(java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Double,java.lang.Long,java.lang.String)! No property update found for type ReferencielParamettre!
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1095) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.data.repository.support.Repositories.cacheRepositoryFactory(Repositories.java:96) ~[spring-data-commons-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.data.repository.support.Repositories.populateRepositoryFactoryInformation(Repositories.java:89) ~[spring-data-commons-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.data.repository.support.Repositories.<init>(Repositories.java:82) ~[spring-data-commons-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.data.repository.support.DomainClassConverter.setApplicationContext(DomainClassConverter.java:109) ~[spring-data-commons-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.data.web.config.SpringDataWebConfiguration.addFormatters(SpringDataWebConfiguration.java:130) ~[spring-data-commons-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.web.servlet.config.annotation.WebMvcConfigurerComposite.addFormatters(WebMvcConfigurerComposite.java:81) ~[spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration.addFormatters(DelegatingWebMvcConfiguration.java:78) ~[spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration.mvcConversionService(WebMvcAutoConfiguration.java:495) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$2afbee97.CGLIB$mvcConversionService$8(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$2afbee97$$FastClassBySpringCGLIB$$1ba8ac87.invoke(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$2afbee97.mvcConversionService(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
... 50 common frames omitted
Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract int mds.ref.common.repository.TypeProduitRepository.update(java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Double,java.lang.Long,java.lang.String)! No property update found for type ReferencielParamettre!
正如M.Deinum在评论中提到的
resultmapping等仅适用于实体或实体包,不适用于任何任意对象。
如果不是在实体里就没办法
又不想工作,我不知道是怎么回事。 日志包含以下消息: 将项目放在github https://github.com/romanych2021/testjpaspring上
它是否将其存储在缓存中?我有一个应用程序,但应用程序中没有任何地方。属性是提到的db详细信息。我可以通过邮递员存储数据和查询它。
是否有一种方法可以使通用Spring数据JPA存储库正确处理类似的方法?例如只返回狗,而不返回所有动物?或者至少,最好的变通方法是什么? 它的工作几乎完美,保存每一个动物在自己的桌子上,等等。唯一的问题是:同时返回水豚和狗。这个答案解释说: 这只有在域类使用单表继承时才起作用。我们在引导时能得到的关于domain类的唯一信息是它将是Product对象。因此,对于像findAll()甚至findBy
如何在一个类中创建和实例化jpa存储库?我现在的情况是,我必须在一个泛型类中为不同的实体创建存储库。 我可以很容易地为Neo4j存储库这样做, 对于JpaRepostory,我检查了留档,发现了这个, 我不确定如何在上面的代码中实例化工厂。 另外,我不能像为Neo4j那样通过指定域类来创建存储库吗?
我们有许多通过接口扩展JpaRepository模式定义的存储库。当运行集成测试或应用程序的某些入口点时,我们只需要这些存储库的一个非常小的子集。 我们可以懒洋洋地加载实际的存储库隐含吗? 相当于@懒在@豆上的东西?注意:我至少尝试了用@lazy注释存储库接口的简单解决方案,但没有成功。