persistence

How to properly test Hibernate length restriction?

I have a POJO mapped with Hibernate for persistence. In my mapping I specify the following: <class name="ExpertiseArea"> <id name="id" type="string"> <generator class="assigned" /> </id> <version name="version" column="VERSION" unsaved-value="null" /> <property name="name" type="string" unique="true" not-null="tr...

Why two subprocesses created by Java behave differently?

I use Java Runtime.getRuntime().exec(command) to create a subprocess and print its pid as follows: public static void main(String[] args) { Process p2; try { p2 = Runtime.getRuntime().exec(cmd); Field f2 = p2.getClass().getDeclaredField("pid"); f2.setAccessible(true); System.out.println( f2.get( p2 ) ); } catch (...

Get location from where the Java code is executed

I have a swing Java application that preserves a lot of data (you can think of a game and its saves for example). Those data are stored in files rather then in database. I would like to keep this files near installation files(.jar file) of my application.Some users(like me) are used to delete default application folder of OS when it com...

How to find out efficiently the auto-generated id for a new object when using JPA?

Hello, I have an attribute which is annotated with @Id. The ID is going to be generated automatically when persisting the object. That means that the ID-value is not defined before I persist the object. After persisting it, it has an ID (in the database), but unfortunately the field still remains null as long as I don't reload it from t...

How to prevent "Local transaction already has 1 non-XA Resource" exception?

Hi, I'm using 2 PU in stateless EJB and each of them is invoked on one method: @PersistenceContext(unitName="PU") private EntityManager em; @PersistenceContext(unitName="PU2") private EntityManager em2; @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW ) public void getCandidates(final Integer eventId) throws ControllerExcept...

How do I Reset the Values in My ASP.NET Fields?

The current form is here. It is not complete, and only a couple options will work. Select "Image CD" and then any resolution and click "Add to Order." The order will be recorded on the server-side, but on the client-side I need to reset the product drop-down to "{select}" so that the user will know that they need to select another pro...

OpenJPA - not flushing before queries

hi all, how can i set openjpa to flush before query. When i change some values in database i want to propagate these changes into application. I tried this settings in persistence.xml: <property name="openjpa.FlushBeforeQueries" value="true" /> <property name="openjpa.IgnoreChanges" value="false"/> false/true - same behavior to my cas...

How do I do automatic data serialization of data objects in Haskell

One of the huge benefits in languages that have some sort of reflection/introspecition is that objects can be automatically constructed from a variety of sources. For example in Java I can use the same objects for persisting to a db (with Hibernate) serializing to XML (with JAXB) or serializing to JSON (json-lib). You can do the same in...

php variable persistance

I have two files: index.php /lib/user.php Index contains the form: <div class="<? echo $msgclass; ?>"> <? echo $msg; ?> </div> <form id="signin" action="/lib/user.php" method="post"> ... </form> User.php makes all the processing. It sets $msg to 'some error message' and $msgalert to 'error' in case of any error. At the end of proc...

Google App Engine ClassNotPersistenceCapableException

I have the following class : import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.PrimaryKey; import com.google.appengine.api.datastore.*; @PersistenceCapable(identityType=Identi...

How do I save a transient object that already exists in an NHibernate session?

I have a Store that contains a list of Products: var store = new Store(); store.Products.Add(new Product{ Id = 1, Name = "Apples" }; store.Products.Add(new Product{ Id = 2, Name = "Oranges" }; Database.Save(store); Now, I want to edit one of the Products, but with a transient entity. This will be, for example, data from a web browser...

Ways to store data in .NET

I am looking for ways to store data in a windows form application in .NET. I want to make the input data of a system persistent, so when I close my program and open it again, the data is retrieved. Which ways are of doing this besides creating a linked database? Examples are gladly appreciated regards ...

MVC Paging and Sorting Patterns: How to Page or Sort Re-Using Form Criteria

What is the best ASP.NET MVC pattern for paging data when the data is filtered by form criteria? This question is similar to: http://stackoverflow.com/questions/1425000/preserve-data-in-net-mvc but surely there is a better answer? Currently, when I click the search button this action is called: [AcceptVerbs(HttpVerbs.Post)] pu...

Which are the differences/similarities between hibernate and other frameworks or specifications?

I want to know the differences/similarities between Hibernate and simple persistence in Java EE 5? I'm not clear if Hibernate implements Java EE 5 persistence implementation or if it is a totally different approach to data representation over back-end systems. I'm confused about Hibernate and its relation with the concepts about java p...

JPA @OneToMany and composite PK

Good Morning, I am working on project using JPA. I need to use a @OneToMany mapping on a class that has three primary keys. You can find the errors and the classes after this. If anyone has an idea! Thanks in advance! FF javax.persistence.PersistenceException: No Persistence provider for EntityManager named JTA_pacePersistence: P...

How to do multiple column UniqueConstraint in hbm?

Working on some legacy hibernate code. How do I do the following with hbm.xml(hibernate mapping file) instead of with annotations? @Table(name="users", uniqueConstraints = { @UniqueConstraint(columnNames={"username", "client"}), @UniqueConstraint(columnNames={"email", "client"}) }) public class User implements Serializable { ...

What data structure to use / data persistence

I have an app where I need one table of information with the following fields: field 1 - int or char field 2 - string (max 10 char) field 3 - string (max 20 char) field 4 - float I need the program to filter on field 1 based upon a segmented control and select a field 2 from a picker. From this data I need to look up field 4 to use ...

How can I persist sessions between a Ruby on Rails mongrel cluster and a Tomcat server?

Title says it all. I have a hybrid Ruby on Rails/GWT system and need to persist session data between the two servers, such that when a user is logged into the Rails system they are "logged in" to the GWT/Tomcat system, and vice versa. Anyone know of a simple way to do this? ...

again about JPA/Hibernate bulk(batch) insert

Here is simple example I've created after reading several topics about jpa bulk inserts, I have 2 persistent objects User, and Site. One user could have many site, so we have one to many relations here. Suppose I want to create user and create/link several sites to user account. Here is how code looks like, considering my willing to use ...

Hibernate entities: columns without entity properties

Is there a way to "magically" persist a column which is not represented as a property in an entity? Concretely I want to add audit info to an entity without having the audit info on the entity. The audit values are not stored in the entity, but are retrieved from the environment at the time of persisting the entity. This happens in a Aud...