persistence

Do I have to close() every EntityManager?

我是研究僧i 提交于 2019-11-28 15:38:16
I have just started migrating my homegrown persistence framework to JPA. Given that the persistence frameworks hide a lot of the plumbing, I'm interested in knowing if NOT closing EntityManagers will create a resource leak, or if the frameworks will collect and close them for me. I intend in all places to close them, but do I HAVE to? At the moment using TopLink, just because it works with NetBeans easily, but am happy to investigate other JPA providers. It depends how you obtained it. If you created it using EntityManagerFactory you will have to close it no matter what framework you use. If

Do I have to close() every EntityManager?

冷暖自知 提交于 2019-11-28 14:26:37
问题 I have just started migrating my homegrown persistence framework to JPA. Given that the persistence frameworks hide a lot of the plumbing, I'm interested in knowing if NOT closing EntityManagers will create a resource leak, or if the frameworks will collect and close them for me. I intend in all places to close them, but do I HAVE to? At the moment using TopLink, just because it works with NetBeans easily, but am happy to investigate other JPA providers. 回答1: It depends how you obtained it.

Write operations are not allowed in read-only mode - Issue while persisting

一笑奈何 提交于 2019-11-28 14:11:18
I have been facing the below error while trying to save the object to database. I tried the solution mentioned here1 and here2 but no good. I was following a tutorial but the only difference is versions of Spring and Hibernate. I am able to persist the object directly using the SessionFactory but it fails with below error if I try this with HibernateDaoSupport spring.xml <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" /> <property

How do I avoid 'Could not determine Hibernate dialect for database name [H2]!'?

旧巷老猫 提交于 2019-11-28 14:09:09
I am getting this error when running grails run-app : Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property

Best practices for using and persisting enums

房东的猫 提交于 2019-11-28 13:34:51
问题 I've seen several questions/discussions here about the best way to handle and persist enum-like values (e.g. Persisting data suited for enums , How to persist an enum using NHibernate ), and I'd like to ask what the general consenus is. In particular: How should these values be handled in the code? How should they be persisted to a database (as text/as a number)? What are the tradeoffs of different solutions? Note: I moved the explanations originally included in this question to an answer.

docker-compose persistent data on host and container

笑着哭i 提交于 2019-11-28 13:00:51
I have a problem with volumes in docker-compose yml 3.0+ So I know that a volume behaves like a mount.. But I have set up a wiki and when i set a volume in the docker-compose, the data on the container will be removed (hidden) So how can I save data from my container to my host first and the next time I start the container, it will just overrides the data I saved. So the current situation is: I start with "docker-compose up --build" and a volume is created (empty) and will be copied to the container.. Everything in that folder on the container is deleted as a result docker-compose.yml version:

JAXB Configuration was broken by upgrading from JDK 1.7 to JDK 1.8 u05 for collections

五迷三道 提交于 2019-11-28 12:45:00
The code below used to work under the JAXB implementation used by JDK 1.7, but now under JDK 1.8 it's broken. In the code below you will find the key change that seems to make it work in 1.8. The "fix" under 1.8 is not really a fix because it's bad practice to expose internal collections for direct modification by the outside world. I want to control access to the internal list through my class and I don't want to complicate things by making observable collections and listening to them. This is not acceptable. Is there any way to get my original code to work under the JAXB of JD 1.8?

websphere 7 and (application based) open-jpa 2

落花浮王杯 提交于 2019-11-28 12:27:25
I want to not use the built in Websphere 7 jpa plugin, instead use an application WEB-INF/lib/open-jpa 2 and a proprietary persistence provider. I cannot install the OSGI and JPA 2 feature pack for Websphere. Originally, I was getting a sax parse error simply trying to load the persistence.xml (version="2" not supported). The error was thrown by a class in open-jpa 1.2.3. When I run websphere/appserver/bin/wsjpaversion.bat, the open-jpa 1.2.3 jar is displayed. By default it overrides the open-jpa 2 jar in the app. I created a shared library containing the open-jpa 2 jar with this config option

How do I save results of a “for” loop into a single variable?

若如初见. 提交于 2019-11-28 12:19:55
I have a for loop: for x in range(1,13): print ("This was the average temperature in month number " + str(x) + " in Boston, 2014: ", Boston_monthly_temp(x)) This prints out the average monthly temperatures in Boston in 2014, such as: This was the average temperature in month number 1 in Boston, 2014: 26.787096774193547 all the way up until Month Number 12 (December): This was the average temperature in month number 12 in Boston, 2014: 38.42580645161291. All in all, this for loop produces 12 lines. However, I can't figure out how to store the results of this "for" loop into a single variable,

Hibernate Mapping Exception : Repeated column in mapping for entity

懵懂的女人 提交于 2019-11-28 12:05:51
There is a mapping exception for a particular entity. Cant figure out from where the problem is arising. I checked all the mappings 3 times from start to end. Still i am getting a Mapping Exception. Email to employee is mapped only once. but still it is reporting the error repeated mapping Error is: Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.cluster.entity.Email column: EMPLOYEE_ID (should be mapped with insert="false" update="false") at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:680) at org.hibernate.mapping