4

When I want make query in Intellij JPA console I get error that relation "topic" does not exist. Jpql query select t from Topic t. I'm using spring boot, I added jpa to module, persistence toolbar works well, but jpa console doesn't. My thougs that JPA Console not find in right db schema, but datasource selected corect.

JPA console print: [2019-07-19 12:49:59] [42P01] ERROR: relation "topic" does not exist [2019-07-19 12:49:59] Position: 60

Andrew Sneck
  • 724
  • 9
  • 18
  • Apparently there is no table named `topic` in your database. You need to create one first –  Jul 19 '19 at 11:06
  • But in database also in database toolbar is visible :/ – Andrew Sneck Jul 19 '19 at 11:07
  • Maybe you quoted it when you created it? `"Topic"` a different table name than `topic` –  Jul 19 '19 at 11:10
  • tables made automaticaly by orm – Andrew Sneck Jul 19 '19 at 11:26
  • Then your obfuscation layer should be able to generate the correct SQL queries. –  Jul 19 '19 at 11:26
  • Can be problem that I don't have set naming strategy on entity manager factory in persistence toolbar? I don't have idea what I should chose.. – Andrew Sneck Jul 19 '19 at 12:19
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/196708/discussion-between-andrew-sneck-and-a-horse-with-no-name). – Andrew Sneck Jul 19 '19 at 12:48
  • 1
    Add more details: what is the database, how you define mappings? Can you run same query from code? Check e.g. https://stackoverflow.com/questions/30626989/jpa-error-relation-does-not-exist – Andrey Jul 19 '19 at 13:02
  • Yes I'm able run same query from code. But I don't have set naming strategy... screen: [link](https://ctrlv.cz/shots/2019/07/22/t8Ca.png) – Andrew Sneck Jul 22 '19 at 08:21

2 Answers2

7

Did you do all those steps?:

enter image description here

(The IDEA version is 2019.1)

Cepr0
  • 28,144
  • 8
  • 75
  • 101
  • very nice animation, I have all set as you show, but if i try hibernate console it ends by exception: `[2019-07-20 23:11:30] org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 0 and column 0 in FILE C:\Users\ondra\.IntelliJIdea2019.1\system\compiler\agent-chat.87f53839\.generated\Jpa_Console\agent-chat.main-hibernate-1563657080743.cfg.xml. Message: null [2019-07-20 23:11:30] javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.` – Andrew Sneck Jul 20 '19 at 21:12
  • @AndrewSneck Maybe it's related to [JAXB-API and Java version](https://stackoverflow.com/q/51916221/5380322) issue somehow? – Cepr0 Jul 21 '19 at 09:51
  • I add this dependecies: `implementation "javax.xml.bind:jaxb-api:2.2.11" implementation "com.sun.xml.bind:jaxb-core:2.2.11" implementation "com.sun.xml.bind:jaxb-impl:2.2.11" implementation "javax.activation:activation:1.1.1"` and hibernate console now show same error as jpa console specifically: ERROR: relation "topic" does not exist – Andrew Sneck Jul 22 '19 at 08:59
3

I found my mistake in connection to database. I had in field Database value postgres, I replace by chatapp - it is correct schema, and now it works well

Database settings

Andrew Sneck
  • 724
  • 9
  • 18