-
1. Re: newbie PK problem
caetanovendrami Jul 16, 2004 10:05 AM (in response to nathancoast)I think you need an <unknown-pk> configuration.
I'm using postgres with something like that:
<unknown-pk>
<unknown-pk-class>java.lang.Long</unknown-pk-class>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>SERIAL</sql-type>
<auto-increment/>
</unknown-pk>
I don't know the specific configuration for hsqldb -
2. Re: newbie PK problem
aloubyansky Jul 17, 2004 4:35 AM (in response to nathancoast)No need for unknown-pk. Just mark the pk field as <auto-increment/>
-
3. Re: newbie PK problem
nathancoast Jul 17, 2004 6:19 AM (in response to nathancoast)thanks but still no cigar.
<ejb-name>ArtistEntity</ejb-name>
<cmp-field>
<field-name>id</field-name>
<auto-increment/>
</cmp-field>
<cmp-field>
<field-name>artistName</field-name>
</cmp-field>
<cmp-field>
<field-name>recordLabel</field-name>
</cmp-field>
<entity-command name="hsqldb-fetch-key">
</entity-command>
still getting exactly the same error as before:
Could not create entity:java.sql.SQLException: Try to insert null into a non-nullable column in statement [INSERT INTO ARTISTENTITY (artistName, recordLabel) VALUES ('default name', 'default label')]
also tried the unknown-pk which didn't work.
Is it the responsibility of jboss or hypersonic to manage incrementing the pk as the insert statement seems to indicate that jboss is not looking after the pk.
thanks
Nathan -
4. Re: newbie PK problem
nathancoast Jul 17, 2004 6:37 AM (in response to nathancoast)OK, phaps ignore previous post, I don't think the db tables were being recreated. After a restart, deployment gives me this error. I've checked the hypersonic docs and BIGINT is the correct translation for a java.lang.Long PK.
java.sql.SQLException: Wrong data type: ID in statement [CREATE TABLE ARTISTENTITY (id BIGINT NOT NULL IDENTITY, artistName VARCHAR(256), recordLabel VARCHAR(256), CONSTRAINT PK_ARTISTENTITY PRIMARY KEY (id))])
any ideas?
cheers
Nathan -
5. Re: newbie PK problem
aloubyansky Jul 18, 2004 1:55 AM (in response to nathancoast)Looks like IDENTITY can't be defined on BIGINT. Also you should <pk-constraint>false</pk-constraint> for the entity because Hypersonic does not support IDENTITY and PRIMARY KEY constraint at the same time. So the statement should look like
CREATE TABLE ARTISTENTITY (id int NOT NULL IDENTITY, artistName VARCHAR(256), recordLabel VARCHAR(256)) -
6. Re: newbie PK problem
tiredofworkingfortheman Jul 26, 2004 10:44 AM (in response to nathancoast)I'm having the same problem. Nathan, can you post your jbosscmp-jdbc.xml file? I'm all over the board on this and seeing yours would help.
Thanks