• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Issue with hibernate 6 - SQL error or missing database

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
create table named user as such



but when i attempt to retrieve info from it with a controller


i get SQL Error: 1, SQLState: null [SQLITE_ERROR] SQL error or missing database (no such table: user)

checking the created database , i see the actual table name that was created is HTE_user

i m using


uploaded a demo of the issue to github : github.com/yaniv33/sqllite

any idea how to access the generated table correctly ?
 
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Yaniv.

One thing you should be aware of is that a lot of databases are case-sensitive on their table names. I recommend always using lower-case myself. So "user", not "User".

If your schema contains a HTE_User then to access it, code "@Table(name="HTE_User")".

You don't need a 'name=' on @Entity.
 
yaniv man
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the response

i changed to


but now i get the created table name to be HTE_hte_user

i updated the github project ..

** BTW , is there a way to disable this behavior of the database naming ?
 
Tim Holloway
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In truth, that sort of behavior is new to me. Plus I usually don't have Hibernate generate my schemas since I'm usually working against an existing database.

But this may give some insight: https://community.jaspersoft.com/wiki/ht-prefixed-tables-repository-72-release-oracle
 
Bartender
Posts: 2445
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Yaniv,
Try to add spring.jpa-defer-datasource-initialization =true to the application.properties file in your resources folder of your project.
See if that can help.
 
yaniv man
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey ,

changed my application.yml to

spring:
 profiles:
   active: dev
 datasource:
   driver-class-name: org.sqlite.JDBC
   url: jdbc:sqlite:E:\\DDD\\springboot.db
   username:
   password:
 jpa-defer-datasource-initialization: true

but nothing changed :-(

updated the github with this change

** i noticed before my github project was not set to public so it is now..

** after Tim Holloway suggestion , i looked into the prefix and the naming convention ,
i managed to add prefix , but only after the HTE_ which seems to be coming  from some other process ...
 
Himai Minh
Bartender
Posts: 2445
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to take a look at these tutorials how to set up the application.properties:
https://mkyong.com/spring-boot/spring-boot-spring-data-jpa-mysql-example/
or
https://www.digitalocean.com/community/tutorials/spring-data-jpa
I guess you still need to add this property hibernate.dialect to your database's dialect for MySQLite.

Or, you can omit @Table(name) annotation to see if it can create a table user.
 
Tim Holloway
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Himai Minh wrote:
I guess you still need to add this property hibernate.dialect to your database's dialect for MySQLite.


Unquestionably. Since the SQL Standard is not "standard", knowing the dialect you are using allows Hibernate to generate the SQL commands that work for the brand of database you are using.

Incidentally, SQLite is not MySQL. It's a much less capable lightweight system that can run embedded in an app. It's common in a lot of Linux apps, and it's the DBMS built into Android.

Speaking of MySQL, here's  a Spring Boot application configuration for using MySQL under Spring Data Hibernate JPA. It's in the YAML format, which I prefer over the flat properties file, but the options would be the same either way.
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic