Bugs item #1069954, was opened at 2004-11-20 02:34
Message generated for change (Comment added) made by starksm
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=1069954&group_id=22866

Category: JBossCMP
Group: v3.2
Status: Open
Resolution: None
Priority: 5
Submitted By: taab (taab)
Assigned to: Nobody/Anonymous (nobody)
Summary: [patch] LongVersionField - info when empty value

Initial Comment:
I've created table with version column (and forgot to
put not null on version column). So during update I
receive stack trace:
Caused by: javax.ejb.EJBException: Store failed;
CausedByException is:
        null
        at
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:144)
        at
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:635)

Problem is in the code:

public class JDBCLongVersionFieldBridge extends
JDBCCMP2xVersionFieldBridge
{
   public Object updateVersion(EntityEnterpriseContext ctx)
   {
      long current =
((Long)getInstanceValue(ctx)).longValue();
      Long next = new Long(current + 1);
      setInstanceValue(ctx, next);
      return next;
   }
}

In fact code is ok, but DB content is wrong: version
column is null (I populated table in wrong way -
similar could happen when DB is somehow damaged).
(I suspect second problem here - why is version column
being updated? probably dirty checking doesn't like
null in version column).
I would propose to put better info in this case:
   public Object updateVersion(EntityEnterpriseContext ctx)
   {
      try {
       long current =
((Long)getInstanceValue(ctx)).longValue();
      } catch (Exception e) {
          throw exception here with text: "probable
cause:empty value in version column or not-number in
version columnt for primary key:" + primary_key value;
      }

This will give direct info of the problem and save a
lot of time in finding db corruption.
Hope it will be helpfull,
    taab


----------------------------------------------------------------------

Comment By: Scott M Stark (starksm)
Date: 2004-12-29 12:52

Message:
Logged In: YES 
user_id=175228

All issues have been moved to http://jira.jboss.com. Existing
issues have been moved. New issues will be closed with this
canned reponse.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=1069954&group_id=22866


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
JBoss-Development mailing list
JBoss-Development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to