I am using PostgreSQL with Jboss 3.0.8. I want to setup automatic primary key generation so I don't have to add the primary key myself each time. What I have done is created a sequence in Postgres that generates a new priamry by getting me the next value in the sequence. I found out how to do this here: http://www.pirack.com/viewHowto.xphp?id=3
This works in postgres, but in my ejb what I am trying to do is to have a finder method that will find execute this seuence and return the next primary key for me. I will then put this in as the primary key argument in my ejbcreate() method. However, jboss does not recognise my sql statement : @ejb.finder
query="SELECT nextval ('voter_id_SEQ')"
It does not recognise the nextval part. THis works fine in normal SQL. Does anyone know of a way to get around this?
If you need any additional info i.e erro mesages etc. just ask.
Thanks in advance,
EJB QL is not SQL. In the end the way I overcame this was to create a GeneratorBean with two variables: tableName and nextID. It now works for every database under the sun. There are many primary key generators generated by code generators like Lomboz etc.
If you are interested I can let you have my simple code. Write to email@example.com