jpa

JPA - createEntityManagerFactory returns Null

允我心安 提交于 2021-01-27 07:56:18
问题 Noob question here. I'm following this example/tutorial to try and isolate a problem I keep getting on my main project. Problem is, the entityManagerFactory keeps returning null (thus, I get a NullPointerExcept when trying to run the first JUnit test.) I'm currently on Eclipse Indigo (JavaEE) - JRE7 - Hibernate 3.6.7 and JBoss 7 And here's my persistence.xml (again, a copipasta taken right from the tutorial) <persistence> <persistence-unit name="examplePersistenceUnit" transaction-type=

Mapping of composite primary keys and foreign keys with shared columns with JPA/Hibernate

早过忘川 提交于 2021-01-27 07:52:59
问题 I've spent a while trying to figure following JPA/Hibernate mapping with composite primary keys and foreign keys (which share 2 of 3 columns), but no joy so far :(. The sample tables follow (yellow key columns comprise PK, blue key columns comprise FK): And so far, I came with the following mapping (which kind of works - it reads data from the database, but can't write any new Party-AdditionalMessage associations because of the updatable=false, insertable-false): ...other imports... import

Mapping of composite primary keys and foreign keys with shared columns with JPA/Hibernate

爱⌒轻易说出口 提交于 2021-01-27 07:50:31
问题 I've spent a while trying to figure following JPA/Hibernate mapping with composite primary keys and foreign keys (which share 2 of 3 columns), but no joy so far :(. The sample tables follow (yellow key columns comprise PK, blue key columns comprise FK): And so far, I came with the following mapping (which kind of works - it reads data from the database, but can't write any new Party-AdditionalMessage associations because of the updatable=false, insertable-false): ...other imports... import

Mapping of composite primary keys and foreign keys with shared columns with JPA/Hibernate

浪尽此生 提交于 2021-01-27 07:49:56
问题 I've spent a while trying to figure following JPA/Hibernate mapping with composite primary keys and foreign keys (which share 2 of 3 columns), but no joy so far :(. The sample tables follow (yellow key columns comprise PK, blue key columns comprise FK): And so far, I came with the following mapping (which kind of works - it reads data from the database, but can't write any new Party-AdditionalMessage associations because of the updatable=false, insertable-false): ...other imports... import

Changing from Collection to SortedSet

二次信任 提交于 2021-01-27 07:09:48
问题 I'm changing a Collection to a SortedSet because I need it to always be in the same consistent order that they were created in. I've changed my model property from @OneToMany(cascade = CascadeType.ALL, mappedBy = "contentId") private Collection<Footnote> footnoteCollection; to @OneToMany(cascade = CascadeType.ALL, mappedBy = "contentId") private SortedSet<Footnote> footnoteSortedSet; and all relevant functions so Netbeans no longer shows any errors. When I run the app I get the error:

Changing from Collection to SortedSet

。_饼干妹妹 提交于 2021-01-27 07:09:22
问题 I'm changing a Collection to a SortedSet because I need it to always be in the same consistent order that they were created in. I've changed my model property from @OneToMany(cascade = CascadeType.ALL, mappedBy = "contentId") private Collection<Footnote> footnoteCollection; to @OneToMany(cascade = CascadeType.ALL, mappedBy = "contentId") private SortedSet<Footnote> footnoteSortedSet; and all relevant functions so Netbeans no longer shows any errors. When I run the app I get the error:

Hibernate native query optional parameter throws 'operator does not exist: bigint = bytea'

南楼画角 提交于 2021-01-27 06:31:37
问题 I have a query as follows: SELECT id FROM table1 WHERE (:param IS NULL OR id_or_smth = :param) The param parameter is optional, therefore it can be null I createed a javax.persistance.Query To which I then setParameter("param", null) And when I called getResultList() I got the following error: Caused by: org.hibernate.exception.SQLGrammarException: ERROR: operator does not exist: bigint = bytea how can i handle this? 回答1: HQL and Criteria can only work when you specify an actual Entity

Spring JPA data removed after shutdown of application

戏子无情 提交于 2021-01-27 06:09:25
问题 i have an application thats build on Spring boot, using JPA repositories on HSQL database. Problem is that while application is running, I create an entity,and it's persisted correctly to database(can be seen in database manager). But after application shutdown from eclipse, all data is removed; Saving is performed like this @Service public class NotificationService { @Autowired private NotificationRepository notificationRepository; public void notifyRefreshArticles(){ Notification

Spring JPA data removed after shutdown of application

爱⌒轻易说出口 提交于 2021-01-27 06:07:53
问题 i have an application thats build on Spring boot, using JPA repositories on HSQL database. Problem is that while application is running, I create an entity,and it's persisted correctly to database(can be seen in database manager). But after application shutdown from eclipse, all data is removed; Saving is performed like this @Service public class NotificationService { @Autowired private NotificationRepository notificationRepository; public void notifyRefreshArticles(){ Notification

Spring JPA data removed after shutdown of application

允我心安 提交于 2021-01-27 06:07:51
问题 i have an application thats build on Spring boot, using JPA repositories on HSQL database. Problem is that while application is running, I create an entity,and it's persisted correctly to database(can be seen in database manager). But after application shutdown from eclipse, all data is removed; Saving is performed like this @Service public class NotificationService { @Autowired private NotificationRepository notificationRepository; public void notifyRefreshArticles(){ Notification