1

I am using Spring Boot, JPA and Postgres and I have one database with multiple schemas. I implement a web service using JPA and I receive this error:

o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: cross-database references are not implemented: "kaloudia_db_v2.enumeration.unit"

Do you know any way to overcome this error?

My class is

@Entity
@Table(name = "unit", schema = "enumeration", catalog = kaloudia_db_v2")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Unit.findAll", query = "SELECT u FROM Unit u"),
    @NamedQuery(name = "Unit.findById", query = "SELECT u FROM Unit u WHERE u.id = :id"),
    @NamedQuery(name = "Unit.findByNameEn", query = "SELECT u FROM Unit u WHERE u.nameEn = :nameEn"),
    @NamedQuery(name = "Unit.findByNameEl", query = "SELECT u FROM Unit u WHERE u.nameEl = :nameEl")})
public class Unit implements Serializable {
private static final long serialVersionUID = 1L;
@Id

and call of JPA function is:

public Object getAllUnits() {
    List<Unit> units = unitRepository.findAll();
    return units;
}
pik4
  • 1,283
  • 3
  • 21
  • 56
  • Please write application.properties file. – ooozguuur Jan 05 '16 at 23:07
  • 2
    Postgres does not support catalogs (=database) as port of an identifier. You should remove the `catalog=...` attribute from the annotation. –  Jan 05 '16 at 23:40
  • @a_horse_with_no_name If I remove the catalogo=... , I receive this error ***ERROR: relation "enumeration.unit" does not exist*** – pik4 Jan 06 '16 at 09:00
  • 1
    @jackk You are right my friend!! I forgot to change this property: spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/kaloudia_db_v2 It works now!! Thank you and I am sorry. – pik4 Jan 06 '16 at 09:03
  • @psmaster you are welcome . +1 :) – ooozguuur Jan 06 '16 at 12:25

1 Answers1

1

As Jack said, I saw the application properties file and I found out that I forgot to change spring.datasource.url property!!

I am sorry for my question! It works fine now!

pik4
  • 1,283
  • 3
  • 21
  • 56