This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 2849
    
  11

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: 2849
    
  11

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: DB default values with CMPs