Hi Brandon,
I am not familiar with this identity-column and after a look at the
code I discovered that it is simply ignored... Anyway, the way to do
that is to use the following construct:
<auto-increment-table>
<sql>INSERT INTO my_cmp_table (eventid) VALUES (NULL)</sql>
<return-type> java.lang.Long</return-type>
</auto-increment-table>
Baically, the idea is to use the auto-increment-table tag. This tag
expects a SQL, which must insert a row into the table of your CMP and
generate a primary key (eventid must be declared as auto_increment
for a value to be generated).
Thanks,
Gianny
On 17/09/2006, at 4:39 PM, Brandon Dooley wrote:
I began to dig around, and there really isnt any documentation besides
http://publib.boulder.ibm.com/wasce/V1.0.1.0/en/Reference/Plans/
openejb-pkgen-2.0.xsd.html#h1577217937
this place . I altered openejb-jar.xml where I think the key-generator
config goes but its not totally right but I think its close. I've
got no
other leads. Suggestions?
<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1"
xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1">
[...]
<enterprise-beans>
<entity>
[...]
<pkgen:key-generator>
<pkgen:database-generated>
<pkgen:identity-column>eventid</pkgen:identity-column>
</pkgen:database-generated>
</pkgen:key-generator>
[...]
</entity>
</enterprise-beans>
Brandon Dooley wrote:
Hi Gianny,
Thanks for the response, it sounds like I could use an explanation on
providing a primary-key generator. The primary key is an
auto_increment
bigint column in a mysql database and I was not setting it, I thought
mysql would handle it. Thanks again for your help.
Brandon
Gianny Damour wrote:
Hi Brandon,
I suspect that the primary key is null after the execution of
ejbCreate. Are you sure that you are setting it during ejbCreate? If
you want this id to be generated, then you will need to provide a
primary-key generator for this CMP. I can explain you how to do
that,
if need be.
Thanks,
Gianny
On 17/09/2006, at 5:07 AM, Brandon Dooley wrote:
I'm getting this exception when I try and create a new bean that
has setter.
I did find Aaron's post
http://www.nabble.com/CMR-Setters---ejbCreate-
tf407940.html#a1122043
http://www.nabble.com/CMR-Setters---ejbCreate-
tf407940.html#a1122043 but
his was a slightly different error and I'm using CMP Beans not CMR
Beans.
<snip>
Caused by: java.lang.IllegalStateException: Identity not available
at org.tranql.cache.CacheRow.getId(CacheRow.java:163)
at org.tranql.cache.InTxCache.associate(InTxCache.java:43)
at org.tranql.cache.CacheTable.addRow(CacheTable.java:92)
at
org.openejb.entity.cmp.CMPCreateMethod.execute
(CMPCreateMethod.java:
195)
at
org.openejb.dispatch.DispatchInterceptor.invoke
(DispatchInterceptor.java:72)
<snip>
public java.lang.Long ejbCreate(String title, String
description, String
location,
Integer typeId, String url, String type, String creator)
throws
javax.ejb.CreateException {
setTitle(title);
setDescription(description);
setLocation(location);
setTypeid(typeId);
setType(type);
setUrl(url);
setCreator(creator);
return null;
}
--
View this message in context: http://www.nabble.com/CMP-Setter---
ejbCreate-tf2283342.html#a6346879
Sent from the Apache Geronimo - Users forum at Nabble.com.