When I use INDENTITY keys plus the insert-after-ejb-post-create, the
latter tag is simply ignored by jboss.

You see, I have created a CMP/CMR bean to map a table that has both:

* IDENTITY columns as PKs (i.e. DB-generated auto-incremented int) and

* NOT NULL constraints on its foreign keys

For the IDENTITY, I'm using these tags (all XDoclet-generated) in
jbosscmp-jdbc.xml:

        <unknown-pk>
  |             <unknown-pk-class>java.lang.Integer</unknown-pk-class>
  |             <column-name>attribute_key</column-name>
  |             <jdbc-type>INTEGER</jdbc-type>
  |             <sql-type>int</sql-type>
  |             <auto-increment/>
  |     </unknown-pk>
  |     <entity-command name="mssql-fetch-key" 
class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCSQLServerCreateCommand">
  |             <attribute name="pk-sql">select @@IDENTITY</attribute>
  |     </entity-command>
  | 

As for the NOT NULL foreign key constraint I'm using these in jboss.xml:

      <entity>
  |          <ejb-name>AttributeBean</ejb-name>
  |          <local-jndi-name>epiphany/AttributeBean</local-jndi-name>
  |          <configuration-name>INSERT after ejbPostCreate 
Container</configuration-name>
  |         <method-attributes>
  |         </method-attributes>
  |       </entity>
  | 
  | [...]
  | 
  |       <container-configuration extends="Standard CMP 2.x EntityBean">
  |         <container-name>INSERT after ejbPostCreate 
Container</container-name>
  |         <insert-after-ejb-post-create>true</insert-after-ejb-post-create>
  |       </container-configuration>
  | 

Note: NOT NULL FKs are a problem for CMR because the relationship is
established only at ejbPostCreate, thus the INSERT command at
ejbCreate tries to insert a NULL at the FK column.

Both of these work correctly, if used alone. I.e. if I change my model
to not use INDENTITY columns, the insert-after-ejb-post-create
works. Converselly, if I drop the NOT NULL constraint of the foreign
key, things also work fine.

But, as I said, if I try to use both things at once, it seems that the
insert-after-ejb-post-create is ignored, as I see the same error
message as if I hadn't used the insert-after-ejb-post-create tag:

anonymous wrote : Cannot insert the value NULL into column 'attribute_key', 
table 'mltest.dbo.attribute'; column does not allow nulls. INSERT fails.

Am I missing something? Is it really broke? Is there any way to work
these two issues out?

jboss-4.0.0, EJB 2.0 spec

Thanks in advance,

Zorzella


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3859947#3859947

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3859947


-------------------------------------------------------
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-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to