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 Need help 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 "Need help" Watch "Need help" New topic
Author

Need help

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Hi.
I'm creatin a simple EJB system.
I have the following database schema :
Table User :
id PK
name not null
email not null
Here is ejbCreate( ) method :

When running the application in JBoss & MySQl server, I got the following exception :
name field can't be null.
Then I modified my table to allow null values, and every thing is Ok !
any help please ...
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
What values were passed in to ejbCreate?


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

home.create(new Integer(1), name, email);
nothing special !!
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Ah, what I'm getting at is whether name had a null value. Does your code check for this before invoking home.create?
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Yes, All fields have valid values !
Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
Well, first check that the value is not null (in two spots):

1. In ejbCreate, simply do a System.out.println( n );
2. In your client, after create check: System.out.println( myBean.getName() );

If both show it's not null, then I'd check the log for the database (if using JBoss' default, it'd be in hypersonic, so check:
$JBoss_Home/server/data/hypersonic/somelogfile.log"

And see what SQL commands it's executing. It's possible that instead of using:

INSERT INTO MyBean VALUES (1, "My Name", "some@where.com")

it could be using:
INSERT INTO MyBean VALUES (1, null, null)
UPDATE MyBean SET Name = "My Name", Email = "some@where.com" WHERE ID = 1

That would be dumb, but you never know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help