You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by "Marcin Skladaniec (JIRA)" <ji...@apache.org> on 2006/05/02 03:52:53 UTC

[JIRA] Created: (CAY-538) Relationship not refreshed before committing the context.

Relationship not refreshed before committing the context. 
----------------------------------------------------------

         Key: CAY-538
         URL: http://issues.apache.org/cayenne/browse/CAY-538
     Project: Cayenne
        Type: Bug

  Components: Cayenne Core Library  
    Versions: 1.2 [BETA]    
 Environment: I think any platform, but tested on os x and freebsd.
Cayenne 3t
    Reporter: Marcin Skladaniec


I have two sites : site1 and site2 and a room linked to site1
If I change the relationship so the room links to site2, than before I commit the changes both sites are linked to the room.

The code

{
		Expression expression = ExpressionFactory.matchExp(CSite.NAME_PROPERTY, "site1");
		SelectQuery query = new SelectQuery(CSite.class, expression);
		List list = context2.performQuery(query);
		CSite tempsite1 = (CSite)list.get(0);
		
		expression = ExpressionFactory.matchExp(CSite.NAME_PROPERTY, "site2");
		query = new SelectQuery(CSite.class, expression);
		list = context2.performQuery(query);
		CSite tempsite2 = (CSite)list.get(0);
		
		
		expression = ExpressionFactory.matchExp(CRoom.NAME_PROPERTY, "room");
		query = new SelectQuery(CRoom.class, expression);
		list = context2.performQuery(query);
		CRoom temproom = (CRoom)list.get(0);
		
		
		logger.info("site 1 rooms");
		List rooms = tempsite1.getRooms();
		for (int i=0; i<rooms.size();i++) {
			logger.info("\troom "+i+" : "+((CRoom)rooms.get(i)).getName());
		}
		
		logger.info("site 2 rooms");
		rooms = tempsite2.getRooms();
		for (int i=0; i<rooms.size();i++) {
			logger.info("\troom "+i+" : "+((CRoom)rooms.get(i)).getName());
		}
		logger.info("(here relationship is modified)");
		temproom.setSite(tempsite2);
		
		logger.info("site 1 rooms");
		rooms = tempsite1.getRooms();
		for (int i=0; i<rooms.size();i++) {
			logger.info("\troom "+i+" : "+((CRoom)rooms.get(i)).getName());
		}
		
		logger.info("site 2 rooms");
		rooms = tempsite2.getRooms();
		for (int i=0; i<rooms.size();i++) {
			logger.info("\troom "+i+" : "+((CRoom)rooms.get(i)).getName());
		}
}

produces output :
site 1 rooms
	room 0 : room
site 2 rooms
(here relationship is modified)
site 1 rooms
	room 0 : room
site 2 rooms
	room 0 : room

I can publish a small project reproducing this bug.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/cayenne/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira