Rick Roman wrote:
Thanks. The plain sql-query works.
note: It throws an error if I close the connection: con.close(); Does
OJB to take care of this?
yep! Please read the 'note' in "Can I directly obtain a
java.sql.Connection within OJB?"
http://db.apache.org/ojb/docu/guides/connection.html#Can+I+directly+obtain+a%0A++++++++++++++++
regards,
Armin
Armin Waibel wrote:
Hi Rick,
I never tried this before with OJB.
Think PostgreSQL expects something like
"select currval 'my_seq'"
So the easiest way will be a plain sql-query within OJB
http://db.apache.org/ojb/docu/guides/connection.html#Can+I+directly+obtain+a%0A++++++++++++++++
The problem with your mapping can be
- OJB needs at least one field declared as primary key field. Simply
add primarykey="true" (it's independent from the PK declaration in DB)
- The table name is 'my_seq' so OJB will always add 'from my_sql A0'
in the generated query and the column names will start with "A0.".
So I think it will not be possible (but maybe I'm wrong).
You can trace the generated SQL using P6Spy (jar is shipped with OJB)
http://db.apache.org/ojb/docu/faq.html#traceProfileSQL
regards,
Armin
Rick Roman wrote:
I am trying to retrieve the current value of a sequence. I tried
setting the sequence up as a table with currval('my_sequence') as a
column
<class-descriptor class="org.mff.web.db.MySeqDb"
table="my_seq">
<field-descriptor
name="currval"
column="currval('my_seq')"
jdbc-type="BIGINT"
/> </class-descriptor> Criteria criteria = new Criteria();
QueryByCriteria query = new QueryByCriteria(MySeqDb.class, criteria);
MySeqDb ms_db=(MySeqDb)broker.getObjectByQuery(query);
System.out.println("My Seq current val: "+ms_db.getCurrval());
But this give me: org.postgresql.util.PSQLException: ERROR: schema
"a0" does not exist
Is there some proper way to make these kind of queries other than
this kludge (that doesn't work anyway)?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]