Timeline for Keep getting "java.lang.IllegalArgumentException: No query defined for that name" even though I have @NamedQuery with an appropriate name
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 20, 2020 at 10:11 | vote | accept | waifu_anton | ||
| Jun 20, 2020 at 10:11 | answer | added | waifu_anton | timeline score: 1 | |
| Jun 19, 2020 at 14:26 | comment | added | JLazar0 | the moment you use @PersistenceContext private EntityManager entityManager you need to have the persistence unit defined somewhere, try to see how to configure your persistence.xml. To do this, you must define a bean in your applicationContext of the following class org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager, another of the following class org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean with the previous one as property and another of the next class org.springframework.orm.jpa.JpaTransactionManager with the previous one as property | |
| Jun 19, 2020 at 11:18 | comment | added | waifu_anton | I am writing my code according to the example from Pro Spring 5: An In-Depth Guide to the Spring Framework and Its Tools (5th edition). There is no persistance.xml in it | |
| Jun 18, 2020 at 14:28 | comment | added | JLazar0 | In your persistence.xml you set transaction-type="RESOURCE_LOCAL" to your persistence-unit? you put this property <property name="hibernate.archive.autodetection" value="class, hbm" /> to autodetect? | |
| Jun 18, 2020 at 14:08 | comment | added | waifu_anton |
If I understood you correctly, you are talking about something like this @NamedQuery(name = "test", query = "select s from Singer s") and return entityManager.createNamedQuery("test", Singer.class).getResultList(); In this case the result is the same (java.lang.IllegalArgumentException: No query defined for that name [test])
|
|
| Jun 16, 2020 at 16:06 | comment | added | JLazar0 | a priori everything seems correct, could you perform the test by putting a string "test" both in the name of the named query definition and in the createNamedQuery method? | |
| S Jun 15, 2020 at 14:58 | review | Triage | |||
| Jun 15, 2020 at 15:47 | |||||
| S Jun 15, 2020 at 14:58 | history | asked | waifu_anton | CC BY-SA 4.0 |