Depending on how you implemented your bean, you don't have to modify the
code in too many places. For example, if you currently have a method called
setAmount(int) you can do the following:
EJB 1.1 CMP:
1. Create a new method called clearAmount() {amount = null;}
2. Change internal representation of amount to java.lang.Integer
3. Update your setAmount(int value) method to {amount = new
Interger(value);}
4. Change the getAmount() to {return amount.intValue();}, (how will you
handle null?)
EJB 2.0 CMP:
1. Change the field name "amount" to amountValue
2. Create a method called abstract void setAmountValue(Integer value);
3. Create a method called abstract Integer getAmountValue();
4. Change existing void setAmount(int value) to {setAmountValue(new
Integer(value);}
5. Change existing int getAmount() to {getAmountValue().intValue();} you can
fudge to return a 0 if getAmountValue() is null.
7. Add a clearAmount() {setAmountValue(null);} function
Your client can continue using setAmount(int) but when you need to clear the
value you can call clearAmount(); The only things you need to change is the
code using the amount field directly from inside of your bean.
-AP_
-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of Vishnu
Sent: Tuesday, October 16, 2001 6:25 AM
To: [EMAIL PROTECTED]
Subject: Re: setting null in the DB for primitive CMP field
Importance: High
Tony,
thankz for u'r suggestion .in fact i got the same suggestion
some other person also..
Is that the only way (i.e.changing int to Integer)..?
(i'm bit relucatant here as i have to modify the code at lot of places)
vish
-----Original Message-----
From: Tony K. Lawrence [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 16, 2001 5:56 PM
To: [EMAIL PROTECTED]
Subject: Re: setting null in the DB for primitive CMP field
Seeing it is a primary key it cannot be null.
A primary key is used to UNIQUELY identify a row in the database.
Tony
-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]] On Behalf Of Vishnu
Sent: 16 October 2001 08:47
To: [EMAIL PROTECTED]
Subject: setting null in the DB for primitive CMP field
Importance: High
Hi,
I have a CMP field in my Entity bean which is of primitive type , say
int
It is mapped to Database Column which is of type, say NUMBER(18)
How to set null in the DB Column?
When I ignore to call set method in ejbCreate it sets the default value
(i.e 0)
in the data base ...
thankz in advance
Vishnu
========================================================================
===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body of the message "signoff EJB-INTEREST". For general help, send
email to [EMAIL PROTECTED] and include in the body of the message
"help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".