This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

.RepositoryConfigurationExtensionSupport : Spring Data JDBC - Could not safely identify store assign

 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use Intellij and new a project, clone the source from
https://github.com/eugenp/tutorials.git

then in
persistence-modules/spring-data-jpa-repo/pom.xml
I add the following
<properties>
       <start-class>com.baeldung.Application</start-class>
</properties>

then I run
mvn spring-boot:run
inside
IdeaProjects\tutorials\persistence-modules\spring-data-jpa-repo>

but many error thrown like the following:


2023-01-25 01:15:56.061  INFO 4100 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data JDBC - Could not safely identify store assignment for repository candida
te interface com.baeldung.boot.daos.ExtendedStudentRepository; If you want this repository to be a JDBC repository, consider annotating your entities with one of these annotations: org
.springframework.data.relational.core.mapping.Table.
2023-01-25 01:15:56.061  INFO 4100 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data JDBC - Could not safely identify store assignment for repository candida
te interface com.baeldung.boot.daos.InventoryRepository; If you want this repository to be a JDBC repository, consider annotating your entities with one of these annotations: org.sprin
gframework.data.relational.core.mapping.Table.
......
......
2023-01-25 01:15:59.871  WARN 4100 --- [           main] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "crea
te table car (id bigint generated by default as identity, model varchar(255), year integer, primary key (id))" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table car (id bigint generated by default as identity, model varchar(255), year integer, primary k
ey (id))" via JDBC Statement
       at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:458) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:442) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:325) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:169) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:138) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:124) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:168) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:85) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:335) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:471) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1498) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]
       at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.
23.jar:5.3.23]
       at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.23.jar:
5.3.23]
       at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.23.jar:5.3.23]      
       at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.23.jar:5.3.23]
       at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.23.jar:5.3.23]      
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.23.jar:5.3.23
]
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.23.jar:5.3.23]  
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.23.jar:5.3.23]    
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.23.jar:5.3.23]      
       at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.23.jar:5.3.23]
       at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.23.jar:5.3.23]
       at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.23.jar:5.3.23]
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.23.jar:5.3.23]
       at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.23.jar:5.3.23]
       at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.23.jar:5.3.23]      
       at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.23.jar:5.3.23]
       at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.5.jar:2.7.5]
       at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.5.jar:2.7.5]
       at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.5.jar:2.7.5]
       at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.5.jar:2.7.5]
       at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.5.jar:2.7.5]
       at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.5.jar:2.7.5]
       at com.baeldung.Application.main(Application.java:14) ~[classes/:na]
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "create table car (id bigint generated by default as identity, model varchar(255), [*]year integer, pr
imary key (id))"; expected "identifier"; SQL statement:
create table car (id bigint generated by default as identity, model varchar(255), year integer, primary key (id)) [42001-214]
       at org.h2.message.DbException.getJdbcSQLException(DbException.java:502) ~[h2-2.1.214.jar:2.1.214]
.......



what is these error and how to solve it?
 
Bartender
Posts: 2402
13
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Spring Data JPA repo example as shown is using a local MySQL database, do you have that?
Have you ever create a database called baeldung in MySQL as shown?
For now, you can try using H2 embedded DB.

Here is a tutorial from the same author:
https://www.baeldung.com/spring-boot-h2-database
 
peter tong
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Himai Minh wrote:The Spring Data JPA repo example as shown is using a local MySQL database, do you have that?
Have you ever create a database called baeldung in MySQL as shown?
For now, you can try using H2 embedded DB.

Here is a tutorial from the same author:
https://www.baeldung.com/spring-boot-h2-database



Have you ever create a database called baeldung in MySQL as shown?
No, at first I just want to run the example in
https://www.baeldung.com/spring-data-crud-repository-save
which just use H2 database, I don't know when I run
mvn spring-boot:run
inside
IdeaProjects\tutorials\persistence-modules\spring-data-jpa-repo>

it will run all class inside spring-data-jpa-repo folder, sorry I am new to spring-boot, is this because the annotation
@SpringBootApplication
inside spring-data-jpa-repo folder, package com.baeldung, so once start up, it will run all class insdie spring-data-jpa-repo folder, package com.baeldung?

What should I do if I just want to run the example in
https://www.baeldung.com/spring-data-crud-repository-save



 
Himai Minh
Bartender
Posts: 2402
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you just want to run the demo application from your IDE, just run this class:
https://github.com/eugenp/tutorials/blob/master/persistence-modules/spring-data-jpa-repo/src/main/java/com/baeldung/Application.java
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I had the same error when I tried with another code that is very similar, my error in that case was the following:

Syntax error in SQL statement
"create table car (id bigint not null,
brand varchar(255),
color varchar(255),
model varchar(255),
price integer not null,
register_number varchar(255),
[*]year integer not null, primary key (id))"; expected "identifier"; SQL statement:

As you can see, there is a [*] that indicates that this field year is a problem when it tries to create the table in H2 (maybe it could be a reserved word, I don't know). So the solution is the following:

in your application.properties, you should indicate that you will not use the word "year" as a reserved word. The parameter in the file I set up like this:

spring.datasource.url=jdbc:h2:mem:testdb;NON_KEYWORDS=YEAR

after that, I restarted the app and it worked. I hope it can be useful for you.

Nelson Mauricio Ortiz
 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic