wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes DB default values with CMPs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "DB default values with CMPs" Watch "DB default values with CMPs" New topic
Author

DB default values with CMPs

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

We are using a CMP for data access. One of the fields is defined in our database (Oracle) as non-null and has a default value. However, if that field is not set on the CMP, the create() method ends up trying to insert a null into the field, which doesn't work. Is there any way to have it simply leave that field out of the insert and let the database use its default?
Vinay Raj
Ranch Hand

Joined: Jun 19, 2006
Posts: 81
Most of the app. servers would not support such a feature. The app. server that typically supports such advanced features is weblogic. If you are using one check out its documentation else my humble suggestion is to set the default value explicitly in your ejbCreate implementation.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

Oh, right. I forgot to mention that we are using WebLogic, but we're back a rev. on 8.1. It's in the documentation? Where? I did look for it, but so far without success.
 
Don't get me started about those stupid light bulbs.
 
subject: DB default values with CMPs
 
Similar Threads
How to tell a CMP to ignore a field on insert?
Proble with Relationship in Entity Bean
Primiary Key Field
String -> MySQL CLOB
EJB create not using default value for not null column