Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EntityBean and default value of a not null field

 
Mateusz Moroz
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a EntityBean, that has a field



This field has a default value 'N' in the database (Oracle), but the problem is, that if I don't set this field in a bean, the server claims



Is there a method in EJB to automatically set the default value to this field?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about initializing it in the code:

 
Mateusz Moroz
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for answer!
I did this way, and it works but I don't think this is elegant method.
The value is directly hardcoded and it will not resond if the default value in database changes.

Is there is a way (maybe some annotation I don't know), that will set the value in bean by the default value from database (something like @Id for primary keys on sequences)?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic