About Id

issue

@PrePersist not working correctly

I have a method to calculate some values before persisting to the database. So i annotated it with @PrePersist. If i merge an object the annotated method get's called but all members are on their default values. I only tried it with new objects. So merge get's an object with id = null and therefore shoud behave like persist. (I always use merge) If i set a breakpoint before the em.merge(..) call the object is ok. Inside the @PrePersist method all fields are cleared.  ... it with new objects. So merge get's an object with id = null and therefore shoud behave like persist. (I always use merge) If ...

 
forum_thread

Is there any faster select method?

SELECT: TypedQuery<Point> query = em.createQuery("SELECT p FROM Point p WHERE p.id = " + element.getId(), Point.class); List<Point> points = query.getResultList();   WRITE: em.persist(p);   ** the Point class is of the tutorial.   I found the above select method is ten times slower than the write method, in my very simple benchmark. I guess the reason there is no SQL in the write method.   ... ( "SELECT p FROM Point p WHERE p.id = " + element. getId ( ) , Point. class ) ; ... objects can be retrieved by their primary key (object ID) directly using the find  method,  so in this specific case ...

 
forum_thread

persitencia (Preguntas y respuestas)

1ra.pregunta:     tengo un formulario y cuando grabo mas de un registro, solo me grava el ultimo mas no los anteriores. 2da.Pregunta:    Tengo un indice que no es el ID y necesito que mi tabla muestre los datos de acuerdo al indice. Como                          puedo hacerlo?. Alguien me sugiere algo. Gracias   ... 2da.Pregunta: Tengo un indice que no se el ID y necesito que mi tabla muestre los datos de acuerdo al indice. ...

 
api-jdo

unpinAll(oids)

Unpin the parameter instances from the second-level cache.(Method of javax.jdo.datastore.DataStoreCache)

 
api-jpa

TableGenerator.table

(Optional) Name of table that stores the generated id values.(Annotation Element of javax.persistence.TableGenerator)

 
forum_thread

EntityManager.merge gives EntityNotFoundException

Just started using objectdb (2.3.4). Calling EntityManager.merge for a new (non-managed) object gives EntityNotFoundException. I am perplexed by this. See attached test case. Thanks for your assistance. Full error output is: Exception in thread "main" [ObjectDB 2.3.4] javax.persistence.EntityNotFoundException Entity is not found: classdb.Test#'id' (error 631) at com.objectdb.jpa.EMImpl.merge(EMImpl.java:456) at classdb.Test.main(Test.java:32) ... Entity is not found: classdb.Test#'id' (error 631) at com.objectdb.jpa.EMImpl.merge(EMImpl.java:456) ...

 
api-jdo

copyKeyFieldsToObjectId(pcClass, fm, oid)

Copy fields from an outside source to the key fields in the ObjectId.(Method of javax.jdo.spi.JDOImplHelper)

 
forum_thread

java.lang.ClassCastException in OSGi runtime when loading data from DB

Hello, I'm trying to use ObjectDB in an OSGi environment (Karaf 4.0.7). I'm now facing ClassCastExceptions on my "entity" classes when I try to read data from the DB. In a very old (2011?) forum entry this problem was already discussed and it appears to be related to classloader problems. My entity is a dedicated bundle. I have one bundle with the database service (doing the actual objectdb actions -> persist, query etc). ... @Override public Person loadPerson(final Integer id) {   TypedQuery<Person> typedQuery = entityManager.createQuery("SELECT FROM Person p WHERE p.id = 1", Person.class);   Person singleResult = ...

 
api-jdo

jdoCopyKeyFieldsFromObjectId(fm, oid)

Copy fields to an outside consumer from the key fields in the ObjectId.(Method of javax.jdo.spi.PersistenceCapable)

 
forum_thread

PersistenceManager.getObjectsById(Collection,boolean) throwing JDOException

I have a call to getObjectsById(Collection,boolean) that is throwing a JDOException the first time I'm attempting to retrieve an object. If I try again, then the second request succeeds. Any idea why this might occur? We're using ObjectDB 2.2.4_02. The collection being passed in is a HashSet<Object> containing a single oid object (the method is written to support multiple objects, but it seems to only be failing irregularly when only a single oid is present). I'm passing false in as the verification argument. #1 2011-05-24 21:06 I have a call to getObjectsById(Collection,boolean) that is throwing a JDOException the first time I'm attemp ...