This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1683
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What values were passed in to ejbCreate?
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
home.create(new Integer(1), name, email);
nothing special !!
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, All fields have valid values !
 
Dan Bizman
Ranch Hand
Posts: 387
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic