persistence

Difference between configuring data source in persistence.xml and in spring configuration files

让人想犯罪 __ 提交于 2019-11-27 10:17:45
问题 I've seen (and done) data source configuration in two ways (the code below is just for demo): 1) configuration inside persistence units, like: <persistence-unit name="LocalDB" transaction-type="RESOURCE_LOCAL"> <class>domain.User</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/> <property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://localhost"/> <property name=

Setting a JPA timestamp column to be generated by the database?

一笑奈何 提交于 2019-11-27 09:57:21
问题 In my SQL Server 2000 database, I have a timestamp (in function not in data type) column of type DATETIME named lastTouched set to getdate() as its default value/binding. I am using the Netbeans 6.5 generated JPA entity classes, and have this in my code @Basic(optional = false) @Column(name = "LastTouched") @Temporal(TemporalType.TIMESTAMP) private Date lastTouched; However when I try to put the object into the database I get, javax.persistence.PersistenceException: org.hibernate

App Engine local datastore content does not persist

我的未来我决定 提交于 2019-11-27 07:44:50
问题 I'm running some basic test code, with web.py and GAE (Windows 7, Python27). The form enables messages to be posted to the datastore. When I stop the app and run it again, any data posted previously has disappeared. Adding entities manually using the admin (http://localhost:8080/_ah/admin/datastore) has the same problem. I tried setting the path in the Application Settings using Extra flags: --datastore_path=D:/path/to/app/ (Wasn't sure about syntax there). It had no effect. I searched my

docker-compose persistent data on host and container

前提是你 提交于 2019-11-27 07:26:00
问题 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

websphere 7 and (application based) open-jpa 2

放肆的年华 提交于 2019-11-27 07:03:37
问题 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

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

∥☆過路亽.° 提交于 2019-11-27 06:57:20
问题 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

Force Hibernate Insert Without Select Statements

时光毁灭记忆、已成空白 提交于 2019-11-27 06:51:50
问题 I am attempting to insert a new record into a table that I know is unique before hand. I have tried calling save() on the object, but that does a bunch of SELECT statements before doing any INSERTs, which I don't want to do because I know the object is already unique. I am opening a new session for each transaction, which I can see being an issue, but that is a constraint of my domain. Is there some way to force Hibernate to not do any SELECTs before it INSERTs? 回答1: You can use the persist()

Hibernate Mapping Exception : Repeated column in mapping for entity

独自空忆成欢 提交于 2019-11-27 06:50:25
问题 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

Is it possible to remove child from collection and resolve issues on SaveChanges?

为君一笑 提交于 2019-11-27 06:45:50
We are using Entity Framework Code First with Foreign Key relationships. We investigating on ways on handling removing objects from an entities ICollection in our application. When we have an entity with child relationships we can add objects directly to their ICollection using Add method. Now when you use remove you get the error System.InvalidOperationException occurred Message=The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null

Is Hibernate / JPA taking in consideration the transient modifier ( not the annotation )

倾然丶 夕夏残阳落幕 提交于 2019-11-27 06:19:48
问题 I want to avoid serialisation ( in JMS / AMF ) but still persist the field with JPA/Hibernate. Is the transient modifier my friend ? Are @Transient annotation and the transient modifier related or not a all ? The java specification precise that a transient field will not be saved to a persistent storage by a system service. But is hibernate a system service ? ( i dont think so ) http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#78119 And java.io.Serialisable seams to