• Post Reply Bookmark Topic Watch Topic
  • New Topic

entity bean - how to set parameter to Null

 
Jenny Kalinina
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Since in my appl I need to update only one table and it has 135 columns, I decided to use BMP bean (so that not to use setter 135 times). I am not sure if it is a right way?
So I use a loop with HashMap to update and insert. The problem is that I need to set some parameters to Null (when user doesn�t not enter value) and to do that, I try to getColumnType of metadata before executing prepared statement. Looks that it doesn�t work. I have an error �Null pointer exception�. Database is Oracle. It works if to use getColumnType after executing prepared stmt. But I need it before, because setNull required a column type.
Could somebody help how to do that?
Thanks in advance
 
Dana Hanna
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
135 columns does NOT mean 135 update statements. It depends on the container, and from where you are calling ejb methods. What the heck kinda table is this anyway? 135 columns is 3 times as many as i've seen on our biggest tables...
Try just doing setObject(null) or setString(null). Most DBs will just take it, and I believe i've done this in Oracle before.
If not, couldn't you just get the DB schema and type out the column types?!?!
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dana's right, a CMP would have worked for this just fine. What's more, if you wanted to, you could split it up among several CMP's each having the same (Shared) primary key so that you don't have to always fetch back all 135 columns at the same time.
Kyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!