Hmmm..

I just tried the same code on jboss-3.2.1 and the new 3.2.2rc1

The code was functional, ableit not what I want for 3.2.1.
The same ear file deployed into 3.2.2rc1 blew up.

I'd file a bug, but I'm still not certain that I haven't coded up
something wrong (I'm still new at the relations stuff), and it's not
jboss' fault.

So, I'll try to include some more code samples and debugging output
here.  Once again, I'm using xdoclet-1.2b, so you'll see those tags
here.  I'll also only include the relevant columns...

TransactionRef is the foreign key which maps to another bean Transaction
whose primary key is transactionRef.



EventQueueBean.java:

Accessor for the foreign key field:
==============================================================================
        /**
         * getTransactionRef - get TRANSACTION_REF
         *
         * @ejb.interface-method 
         * 
         * @ejb.transaction type="NotSupported"
         * @ejb.persistence column-name "TRANSACTION_REF"
         * @jboss.method-attributes read-only="true"
         * @ejb.value-object
         *              match="Default"
         */
        public abstract java.lang.String getTransactionRef ();

        /**
         * setTransactionRef - set TRANSACTION_REF
         *
         * @ejb.interface-method 
         * @ejb.value-object
         *              match="Default"
         */
        public abstract void setTransactionRef ( java.lang.String aValue
);

==============================================================================
Accessor for the foreign key cmr.
        /**
         * @ejb.interface-method view-type="local"
         * @ejb.transaction type="Required"
         *
         * @ejb.value-object 
         *              match="Tree"
         *             
aggregate="com.navahonetworks.interfaces.entity.TransactionValue"
         *              aggregate-name="TransactionValue"
         *             
members="com.navahonetworks.interfaces.entity.TransactionValue"
         *              members-name="TransactionValue"
         *              relation="external"
         *
         * @ejb.relation
         *              name="EventQueue-Transaction"
         *              role-name="EventQueue-has-a-Transaction"
         *              cascade-delete="false"
         *              target-ejb="Transaction"
         *              target-role-name="Transaction-has-an-EventQueue"
         *              target-multiple="no"
         *
         *
         * @jboss.relation
         *              fk-column="TRANSACTION_REF"
         *              related-pk-field="transactionRef"
         *
         *
         * @jboss.method-attributes read-only="true"
         *
         */
        public abstract
com.navahonetworks.interfaces.entity.TransactionLocal getTransaction();

        /**
         * @ejb.interface-method view-type="local"
         * @ejb.transaction type="Required"
         */
        public abstract void
setTransaction(com.navahonetworks.interfaces.entity.TransactionLocal
transaction);


==============================================================================

Relevant portion of jbosscmp-jdbc.xml:

    <ejb-relation>
      <ejb-relation-name>EventQueue-Transaction</ejb-relation-name>

      <foreign-key-mapping/>

      <ejb-relationship-role>
         
<ejb-relationship-role-name>EventQueue-has-a-Transaction</ejb-relationship-role-name>
                  <key-fields/>

      </ejb-relationship-role>
      <ejb-relationship-role>
         
<ejb-relationship-role-name>Transaction-has-EventQueues</ejb-relationship-role-name>
          <key-fields>
             <key-field>
               <field-name>transactionRef</field-name>
               <column-name>TRANSACTION_REF</column-name>
             </key-field>
          </key-fields>

      </ejb-relationship-role>
    </ejb-relation>

==============================================================================

On Jboss 3.2.1:
Here's the query being executed by jboss cmp on the ejbLoad.  Note that
TRANSACTION_REF appears twice... once for the cmr-field, and once for
the cmp-field.

2003-06-12 16:17:53,522 DEBUG
[org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.EventQueue]
Executing SQL: SELECT EVENT_QUEUE_ID,EVENT_QUEUE_GUID, ENTRY_DATE,
EVENT_TYPE, STATE, TRANSACTION_REF, ATTEMPTS, NEXT_ATTEMPT, PRIORITY,
LOCKED, EVENT_DETAILS, VENDOR_ID, VENDOR_ID, TRANSACTION_REF FROM
OFFNET.EVENT_QUEUE WHERE (EVENT_QUEUE_ID=?) OR (EVENT_QUEUE_ID=?) OR 
(EVENT_QUEUE_ID=?)

This isn't exactly what I want - I'd rather see just one
"TRANSACTION_REF" show here, but it appears to work.  (I'm worried about
what an ejbStore would do - would it try to set it twice? I'll have to
check that).


==============================================================================

On Jboss 3.2.2-RC1:

The exact same client and ejbs as above blows up with the following
trace (sorry about the linewraps).  I note that the query still asks for
TRANSACTION_REF twice.  There's quite a bit more stack trace if that
helps anyone.



2003-06-12 16:04:56,406 DEBUG
[org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.EventQueue]
Executing SQL: SELECT EVENT_QUEUE_GUID, ENTRY_DATE, EVENT_TYPE, STATE,
TRANSACTION_REF, ATTEMPTS, NEXT_ATTEMPT, PRIORITY, LOCKED,
EVENT_DETAILS, VENDOR_ID, TRANSACTION_REF, VENDOR_ID FROM
OFFNET.EVENT_QUEUE WHERE (EVENT_QUEUE_ID=?)
2003-06-12 16:04:56,406 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.eventQueueId] 
Set parameter: index=1, jdbcType=INTEGER, value=4803
2003-06-12 16:04:56,414 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.eventQueueGuid] 
Get result: index=1, javaType=java.lang.String, Simple, value=null
2003-06-12 16:04:56,415 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.entryDate] Get 
result: index=2, javaType=java.sql.Timestamp, Simple, value=2003-06-10 11:30:22.0
2003-06-12 16:04:56,415 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.eventType] Get 
result: index=3, javaType=java.lang.Integer, Simple, value=202003-06-12 16:04:56,415 
TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.state] 
Get result: index=4, javaType=java.lang.Integer, Simple, value=0
2003-06-12 16:04:56,415 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.transactionRef] 
Get result: index=5, javaType=java.lang.String, Simple, value=BBBBBBBBBYB3
2003-06-12 16:04:56,415 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.attempts] Get 
result: index=6, javaType=java.lang.Integer, Simple, value=2382003-06-12 16:04:56,416 
TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.nextAttempt] 
Get result: index=7, javaType=java.sql.Timestamp, Simple, value=2003-06-12 16:16:09.0
2003-06-12 16:04:56,416 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.priority] Get 
result: index=8, javaType=java.lang.Integer, Simple, value=0
2003-06-12 16:04:56,416 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.locked] Get 
result: index=9, javaType=java.lang.String, Simple, value=N
2003-06-12 16:04:56,416 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.eventDetails] 
Get result: index=10, javaType=java.lang.String, Simple, 
value=<event><post><url>aHR0cHM6Ly9hcHB0ZXN0Lm5hdmFob25ldHdvcmtzLmNvbS9uYXZhaG8vU2VsZWN0RGlhbGVy</url><nvpair><param_name>U1RBVEU=</param_name><param_value>QUJBTkRPTkVE</param_value></nvpair><nvpair><param_name>VFJBTlNBQ1RJT05fSUQ=</param_name><param_value>Mzc4NTU5OQ==</param_value></nvpair><nvpair><param_name>VFJBTlNBQ1RJT05fUkVG</param_name><param_value>QkJCQkJCQkJCWUIz</param_value></nvpair><nvpair><param_name>SU5WT0lDRV9OTw==</param_name><param_value>MTA1NTI1ODM0MTc2OQ==</param_value></nvpair><nvpair><param_name>Q09NUExFVElPTl9EQVRF</param_name><param_value>MjAwMzA2MTAxNjEwNTY=</param_value></nvpair><nvpair><param_name>U0lURV9VU0VSTkFNRQ==</param_name><param_value>dXNlcg==</param_value></nvpair><nvpair><param_name>U0lURV9QQVNTV09SRA==</param_name><param_value>cGFzcw==</param_value></nvpair><nvpair><param_name>VkVORE9SX0lE</param_name><param_value>MQ==</param_value></nvpair><nvpair><param_name>VkVORE9SX0FNT1VOVA==</param_name><param_value>MTUuMDA=</param_value></nvpair><nvpair><param_name>VkVORE9SX0NVUlJFTkNZX0lE</param_name><param_value>MQ==</param_value></nvpair><nvpair><param_name>VkVORE9SX0NVUlJFTkNZX1NZTQ==</param_name><param_value>Q0FE</param_value></nvpair><nvpair><param_name>U0hPUFBFUl9BTU9VTlQ=</param_name><param_value>MA==</param_value></nvpair><nvpair><param_name>U0hPUFBFUl9DVVJSRU5DWV9JRA==</param_name><param_value>MQ==</param_value></nvpair><nvpair><param_name>U0hPUFBFUl9DVVJSRU5DWV9TWU0=</param_name><param_value>Q0FE</param_value></nvpair></post></event>
2003-06-12 16:04:56,417 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.vendorId] Get 
result: index=11, javaType=java.lang.Integer, Simple, value=1
2003-06-12 16:04:56,417 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.transactionRef] 
Get result: index=12, javaType=java.lang.String, Simple, value=BBBBBBBBBYB3
2003-06-12 16:04:56,417 TRACE
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.EventQueue.vendorId] Get 
result: index=13, javaType=java.lang.Integer, Simple, value=1
2003-06-12 16:04:56,425 ERROR [org.jboss.ejb.plugins.LogInterceptor]
TransactionRolledbackLocalException, causedBy:
javax.ejb.EJBException: Error in getRelatedId; CausedByException is:
        null
        at
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getRelatedEntityByFK(JDBCCMRFieldBridge.java:650)
        at
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getInstanceValue(JDBCCMRFieldBridge.java:572)
        at
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getValue(JDBCCMRFieldBridge.java:517)
        at
org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:124)
        at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
        at
com.navahonetworks.ejb.entity.EventQueueCMP$Proxy.getTransaction(<generated>)
        at
com.navahonetworks.ejb.entity.EventQueueCMP.getEventQueueTreeValue(EventQueueCMP.java:94)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1059)
        at
org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:95)
        at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:301)
        at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
        at
org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:82)
        at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:174)
        at
org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
        at
org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)
        at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
        at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
        at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
        at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)






On Thu, 2003-06-12 at 12:27, Alexey Loubyansky wrote:
> Hello Russell,
> 
> it should work properly. Try to upgrade your JBoss version. If the
> issue is still there then submit a bug report.
> 
> alex
> 
> Thursday, June 12, 2003, 5:29:05 PM, Russell Chan wrote:
> 
> RC> Hi,
> 
> RC> I'm trying to find out if I can have a CMP EJB with a cmp-field
> RC> accessors and cmr-field accessors mapping to the same database
> RC> column/foreign key.
> 
> RC> I'm using jboss-3.2.1 with cmp2 (and xdoclet-1.2b)
> 
> RC> In my case, the actual foreign key is enough for some circumstances, and
> RC> I don't want to trigger off another database read just to get the
> RC> foreign key that's already in the table and that the cmp engine should
> RC> already know about. 
> 
> RC> Having traced through the sql being generated, if I include accessors on
> RC> the column as cmp-fields and a cmr-relation on the same field, the CMP
> RC> engine appears to be including the column twice in the generated sql. 
> RC> I'm also worried about the effect this will have on updates/inserts.
> 
> RC> Is there any way to properly do this in jboss-3.2.1?
> 
> RC> I've searched through the archives, and noticed a couple of people
> RC> asking this same question.  The answer at the time was "not yet
> RC> supported, but soon", but that was way back in December 2002.
> 
> RC> Thanks,
> RC> Russ
> 
> 
> 
> -------------------------------------------------------
> This SF.NET email is sponsored by: eBay
> Great deals on office technology -- on eBay now! Click here:
> http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
> 




-------------------------------------------------------
This SF.NET email is sponsored by: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to