Home > OS >  I am using JAVA Spring Boot REST API and Hibernate/JPA issue is with table name when the name I need
I am using JAVA Spring Boot REST API and Hibernate/JPA issue is with table name when the name I need

Time:12-02

The problem is when hibernate builds the query it ignores the dot and sets the prepared statement "from" to look like

"from foo_bar" when it needs to actually be "foo.bar" So even though it connects to the primary database fine it never finds the table. This is a DB2 schema where it is Database->table.sub-table ( not a join but a naming convention the DBA's use).

I have tried adding the dot in the @Table name prop

A snippet example is like:

@Entity
@Table(name="FOO.BAR")
public class SomeClassName {

}

I tried using the application.properties spring.datasource.url=jdbc:db2://server:port/dbname and modifying that. Any ideas? Do I need to create my own naming convention or something?

CodePudding user response:

Welcome to stackoverflow Richard.

I am fairly confident that the first value would be considered the schema name.

Perhaps trying the following would work?

@Entity
@Table(name="BAR" schema="FOO")
public class SomeClassName {

}
  • Related