I don't think it can be done. As Andrus was suggesting, JDBC doesn't seem to have a way to read those values from the database schema. The only portable approach I can think of is using SQLtemplate to create a dummy object at system startup, read back its values and then delete that record.

It seems like an unusual request though - can you not simply implement the default values within Cayenne rather than within the database? Or else use the mysql command "SHOW CREATE TABLE" to get the default values and map them onto the right attributes at startup. Then you can populate the values in prePersist() or wherever is appropriate as each record is created.

Ari Maniatis



On 23/12/2007, at 10:12 AM, Adam Yocum wrote:

Hi Ari,

 It looks like I can get close with ...

 
http://cayenne.apache.org/doc/api/org/apache/cayenne/map/DbAttribute.html#getType()

That returns the SQL type that of the DbAttribute, if only I could get the Default Value set in the database.

 I need something like DbAttribute.getDefaultValue();

 suggestions?

 Thanks,
 Adam

Aristedes Maniatis <[EMAIL PROTECTED]> wrote:

On 23/12/2007, at 5:30 AM, Adam Yocum wrote:

'SHOW columns FROM tablename'

This might be a good starting point:

http://cayenne.apache.org/doc/api/org/apache/cayenne/map/ObjEntity.html#getAttributes()

Ari Maniatis



-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001 fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A





---------------------------------
Looking for last minute shopping deals? Find them fast with Yahoo! Search.





-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Reply via email to