cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cghersi <cristiano.ghe...@abodata.com>
Subject Re: Temporary ID hasn't been replaced on commit
Date Mon, 05 Mar 2012 16:50:59 GMT
Here there is the snippet of code that I use to save my object:
        ...
        private AtomicReference<DataContext> context = new
AtomicReference<DataContext>(config.getDomain("PacketDomain").createDataContext());
	private <E> void CommitObjects(Class<E> objClass){
		synchronized(context){
			try{
				context.get().commitChanges();
			} catch(ValidationException e){
				log.warn("Validation failed. " + objClass.getName() +" discarded\n");
				e.printStackTrace();
				try{
					context.get().rollbackChanges();
				} catch(Exception e1){
					e1.printStackTrace();
				}
			} catch(Exception e){
				e.printStackTrace();
				try{
					context.get().rollbackChanges();
				} catch(Exception e1){
					e1.printStackTrace();
				}
				
			}
			log.debug("Registered Count:
"+context.get().getObjectStore().registeredObjectsCount());
			log.debug("New Count: "+ context.get().newObjects().size());
			log.debug("Delete Count: "+ context.get().deletedObjects().size());
			log.debug("Modify Count: "+ context.get().modifiedObjects().size());
			log.debug("Cache Size: "+context.get().getQueryCache().size());
			context.get().getObjectStore().getDataRowCache().clear();
			context.get().getQueryCache().clear();
		}
	}


Moreover, as you can see, I tried to add a synchronization on context in the
method that commit objects: the result has been a NullPointerException in
DataObjectUtils.java, line 114:
ObjectId id = dataObject.getObjectId();
        if (!id.isTemporary()) {
            return id.getIdSnapshot();
        }
on "id" object.

Is there any other clues that may I provide?

Thank you very much
Best
cghersi


--
View this message in context: http://cayenne.195.n3.nabble.com/Temporary-ID-hasn-t-been-replaced-on-commit-tp3801043p3801212.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Mime
View raw message