-
1. Re: CMP: Irregular updates of database??
acoliver Oct 2, 2005 7:08 PM (in response to anthropophagos)The scope of the transaction governs the commit. Execution of finders forces a flush.
At this point you should probably be looking to move to Hibernate or EJB3. I'd say that the bulk of newer JBoss-based systems (if not on the whole) are now deployed using Hibernate or similar and not CMP2. The EJB3 persistence model is essentially Hibernate. -
2. Re: CMP: Irregular updates of database??
anthropophagos Oct 3, 2005 5:17 AM (in response to anthropophagos)Thank you for your response!
I managed to narrow my problem to the following:
There is a CMP field
getVersionHash()
setVersionHash()
which contains a java.util.HashMap <Integer, VersionInfo>
VersionInfo is a class which looks like this:
public class VersionInfo implements java.io.Serializable{
private static final long serialVersionUID = 123567890L;
public String user = null;
public long version = 0;
public long lastUserVersion = 0;
}
What I do not understand now is the following problem:
HashMap verMap = getVersionHash();
VersionInfo verInfo = (VersionInfo)verMap.get(typeCode);
//verInfo.version = verInfo.version+1; // NO SQL UPDATE
//verMap.put(typeCode, verInfo);
VersionInfo newVer = new VersionInfo(); // SQL UPDATE
newVer.user = verInfo.user;
newVer.lastUserVersion = verInfo.lastUserVersion;
newVer.version = verInfo.version+1;
verMap.put(typeCode, newVer);
If the first approach is being used, there is no SQL UDATE at all, meaning the occured change to the Hash is NEVER commited to Database
If I use the second approach, changes to the Hash are commited to Database immediately.
Am I missing anything? what's wrong?
Thank you in advance,
Jannis