• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB create not using default value for not null column

 
Nick Kelly
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having problems getting my EJB create method to use the default value for a not null column.

This is an ORACLE database and the entity beans are using CMP.

I have a table with a field, say z, that is not null and has a default value specified in the database.

In an ordinary SQL window the following works:

insert into app_orders (x,y) values (9999999, 'test')

There is existing code like this:

order = getOrderHome().create(orderPk,orderNumber);

But when this is executed we get the error:

javax.ejb.CreateException: Could not create entity:java.sql.SQLException: ORA-01400: cannot insert NULL into ("XXX"."APP_ORDERS"."Z")

Can we do something to make the EJB use the default value?

Thanks
 
Jeremy Hsu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah
create another Create method that takes only the primary key.

and u call that when u detect orderNumber == NULL.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic