-
1. Re: java.lang.Long primary key and Postgres
lorensrosen Jan 16, 2003 2:07 PM (in response to hansbaus)I have Long keys working Postgres. Can you try running postmaster with the -d 2 flag so we can see precisely the SQL that it doesn't like?
-
2. Re: java.lang.Long primary key and Postgres
hansbaus Jan 17, 2003 3:49 AM (in response to hansbaus)> I have Long keys working Postgres. Can you try
> running postmaster with the -d 2 flag so we can see
> precisely the SQL that it doesn't like?
this is the primary key part:
CONSTRAINT pk_myprimarykey PRIMARY KEY ())
exactly what I thought: the key field name is missing.
The type of the primary key field is also java.lang.Long
but of course the EjbClassPK class is not generated.
I guess it cannot find the type and then fails to set the name.
I'll try to run the example project with Postgres and Long keys.
Hans -
3. Re: java.lang.Long primary key and Postgres
hansbaus Jan 17, 2003 4:23 AM (in response to hansbaus)This is the full output for the original example (*):
DEBUG: query: CREATE TABLE testentity (Id INT4 NOT NULL, First_Name TEXT,
Last_Name TEXT, Password TEXT, Email TEXT, Address TEXT,
City TEXT, ZIP TEXT, State TEXT, Country TEXT, Creation_Date DATE,
Modification_Date DATE, CONSTRAINT pk_testentity PRIMARY KEY (Id))
NOTICE: CREATE TABLE/PRIMARY KEY will create
implicit index 'pk_testentity' for table 'testentity'
DEBUG: ProcessUtility: CREATE TABLE testentity (Id INT4 NOT NULL,
First_Name TEXT, Last_Name TEXT,
Password TEXT, Email TEXT, Address TEXT,
City TEXT, ZIP TEXT, State TEXT, Country TEXT, Creation_Date DATE,
Modification_Date DATE, CONSTRAINT pk_testentity PRIMARY KEY (Id))
DEBUG: ProcessUtility: CREATE TABLE testentity (Id INT4 NOT NULL,
First_Name TEXT, Last_Name TEXT,
Password TEXT, Email TEXT, Address TEXT,
City TEXT, ZIP TEXT, State TEXT, Country TEXT, Creation_Date DATE,
Modification_Date DATE, CONSTRAINT pk_testentity PRIMARY KEY (Id))
Then I added the tag
@ejb:pk class="java.lang.Long"
to src/main/ejb/test/entity/TestEntityBean.java in the jboss example.
This is the failing SQL I get:
CREATE TABLE testentity (Id INT4 NOT NULL,
First_Name TEXT, Last_Name TEXT,
Password TEXT, Email TEXT, Address TEXT,
City TEXT, ZIP TEXT, State TEXT, Country TEXT, Creation_Date DATE,
Modification_Date DATE, CONSTRAINT pk_testentity PRIMARY KEY ())
You can download my modified example from:
http://knuth.marketxs.com/~hans/jboss/jboss3example.tar.gz
My postgres version 7.1.3
Hans Bausewein
(*) I've modified the example to get working xdoclet tags. See my posts on
forum "Getting Started Documentation" in december. -
4. Re: java.lang.Long primary key and Postgres
hansbaus Jan 17, 2003 5:31 AM (in response to hansbaus)I've made a some small modifications to the example project:
'TestEntityBean.java':
- the type of id changed from 'int' to 'java.lang.Integer'
- removed class 'TestEntityBeanPK' from the import list.
- return type of 'ejbCreate' is now 'java.lang.Integer'
'SequenceGeneratorBean':
- uses Postgres instead of Hypersonic
The xdoclet tag to add is:
@ejb:pk class="java.lang.Integer"
Check the date and size of 'TestEntityBean.java':
15725 Jan 17 11:26 TestEntityBean.java
To run the example, you need to create a sequence in Postgres:
CREATE SEQUENCE SeqTestEntity;
to test it:
SELECT Nextval( 'SeqTestEntity' );
Hans -
5. Re: java.lang.Long primary key and Postgres - FIXED :-)
hansbaus Jan 17, 2003 6:25 AM (in response to hansbaus)Found the problem :-)
Add to '@ejb:bean' tag this attribute: primkey-field="Id"
This adds the extra
<primkey-field>Id</primkey-field>
to the bean's entity in 'ejb-jar.xml'
I've also found some xdoclet documentation:
http://xdoclet.sourceforge.net/using.html
Hans