File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes EJB create not using default value for not null column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB create not using default value for not null column" Watch "EJB create not using default value for not null column" New topic
Author

EJB create not using default value for not null column

Nick Kelly
Ranch Hand

Joined: Jan 28, 2005
Posts: 45
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

Joined: Mar 28, 2005
Posts: 79
yeah
create another Create method that takes only the primary key.

and u call that when u detect orderNumber == NULL.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB create not using default value for not null column