persistence

How to configure & package a simple Java app to use JPA

三世轮回 提交于 2019-12-13 04:18:45
问题 I'm trying to learn JPA and I want create a simple Java command line app that will use JPA to query and update a database table. I mapped out the the simple code needed to do this. But I don't know how to configure the directory structure, where to place the persistence.xml file, packaging and so on. This is just a quick and dirty learning exercise so I want to keep this as simple as possible. Can someone spell out the steps in order to do this? I'm using Weblogic 10.3. 回答1: persistence.xml

SerializationException when deserializing

▼魔方 西西 提交于 2019-12-13 02:48:17
问题 This code deserialize object from SQLite. I'm get serialized object from DBinaryData (BLOB) field. But get System.Runtime.Serialization.SerializationException: end of stream encountered before parsing was completed. How to fix this? public void Dump() { try { const string databaseName = @"C:\Code\C#\WcfService\WcfService\mainDB.db3"; SQLiteConnection connection = new SQLiteConnection(string.Format("Data Source={0};", databaseName)); connection.Open(); try { SQLiteCommand command = new

Hibernate provides next generated id 32768 and so on 65536, 98304

佐手、 提交于 2019-12-13 02:37:51
问题 EMPLOYEE.java @Entity @Table(name="EMPLOYEE") public class Employee implements Serializable { @Id @GeneratedValue( strategy = GenerationType.TABLE) EMPLOYEE (TABLE) 1 3/13/2013 911 Jack Bauer 32768 3/13/2013 911 Jack Bauer 65536 3/13/2013 911 Jack Bauer 98304 3/13/2013 911 Jack Bauer HIBERNATE_SEQUENCES(TABLE) HOLDING CORRECT NUMBER EMPLOYEE 4 回答1: @TableGenerator(name="tabgen",table="employee-id",pkColumnName="name",valueColumnName="value",allocationSize=1) @GeneratedValue(strategy

How to persist from build programmatically?

戏子无情 提交于 2019-12-13 01:28:00
问题 I want to be able to load some information programmatically into Properties.Settings.Default before I publish it, but it doesn't persist. How do I overcome that? I have (as a test): private void button1_Click(object sender, EventArgs e) { Properties.Settings.Default.Setting1 = "abc"; Properties.Settings.Default.Save(); } private void button2_Click(object sender, EventArgs e) { Text = Properties.Settings.Default.Setting1; } I clicked on button1, then published (with clickonce) and then run the

EclipseLink persistence and refresh both association entities

百般思念 提交于 2019-12-13 00:36:00
问题 I'm using EclipseLink in my Java EE project with a PostgreSQL database. I have trouble finding the right annotations for a correct behaviour when I persist/refresh entities which are part of oneToMany/manytoOne associations. For example, I have an entity "Project" which is first created by the users through a UI. Then the users can add "Analysis" into the project they created. Hence, an analysis is part of one project and a project can have several analysis. The persist action works fine (I

Error (org.codehaus.mojo) when adding persistence to Maven-Java-project?

北城以北 提交于 2019-12-13 00:12:11
问题 When adding persistence to my Maven-Java-project I can successfully build and compile ("Clean and Build Project" in Netbeans, I suppose it does mvn site ) the project, but I won't be able to start it afterwards ("Run Project" in Netbeans). I have been trying around for some time without success. For instance I have tried to delete the org.codehaus.mojo plugin in the pom.xml though there was no changement in my success. Does anyone know this problem? Is there any wrong configuration with my

Hazelcast file persistence (MapStore implementation)

拈花ヽ惹草 提交于 2019-12-12 21:55:02
问题 I am using Hazelcast for clustered data distribution. I read in the documentation about data persistence, using the interfaces MapStore and MapLoader. I need to implement these interfaces and write the class name in the hazelcast.xml file. Is there any example of implementation of these interfaces for file persistence with hazelcast? Does anyone know about any source code or jar file that I can download and work with? Thanks 回答1: You can implement your own just using ObjectOutputStream and

JPA - getting distinct value from one column

我们两清 提交于 2019-12-12 12:53:22
问题 I have an entity that has few fields. One of them is city name. Now I want to get list of all distinct cities from that table. How can I archive that. I tried using DISTINCT keyword, but it doesn't work. I'm using Hibernate as JPA provider but I would like to get it in pure JPA Query. 回答1: Have you tried: SELECT DISTINCT t.city FROM MyTable t 来源: https://stackoverflow.com/questions/3600870/jpa-getting-distinct-value-from-one-column

Persistent Akka Mailboxes and Losslessness

主宰稳场 提交于 2019-12-12 12:24:18
问题 In Akka, when an actor dies while processing a message (inside onReceive(...) { ... } , that message is lost. Is there a way to guarantee losslessness? Is there a way to configure Akka to always persist messages before sending them to onReceive , so that they can be recovered and replayed when the actor does die? Perhaps something like a persistent mailbox? 回答1: Yes, take a look at Akka Persistence, in particular AtLeastOnceDelivery. This stores messages on the sender side in order to also

entityManager.persist(user) -> javax.persistence.EntityExistsException: User@b3089 is already persistent

余生长醉 提交于 2019-12-12 12:16:48
问题 // lookup existing user & set a currently null child entity (ContactInfo) user.setContactInfo(contactInfo); // update the user in the datastore with newly created child Entity entityManager.persist(user); Generates exception: javax.persistence.EntityExistsException: User@b3089 is already persistent Since the user already exists, is there some other method besides entityManager.persist that I should be using for an update instead of an insert? 回答1: Your user instance is already loaded in the