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 How to manage CMP field with Boolean type???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to manage CMP field with Boolean type????" Watch "How to manage CMP field with Boolean type????" New topic
Author

How to manage CMP field with Boolean type????

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi,

I am developing EJB application with CMP2.X specification. I have 2 fields with boolean datatype in my database. When I am trying to put getter n setter for those beans as follows:-
============
public Boolean getQuoted() {
return quoted;
}

public void setQuoted(Boolean quoted) {
this.quoted = quoted;
}

==============

& when i m deploying bean on server n when i m executing client on bean i m getting error like:-
==========
Cannot create CDBean: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: EJBException:; nested exception is:
javax.ejb.EJBException: Internal error setting parameters for field quoted; CausedByException is:
Unknown Types value.
==========

& when i m removing those fields in my EJB with boolean type, It works fine n record gets inserted in DB.

Please tell me how to manage fields with boolean type.

Thanx,

Prash


********Deserve Before You Desire********
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
I remember vaguely hitting something like this once before in a CMP layer. I'd suggest experimenting with the column definition in the table, try different types. I think the problem had something to do with default type conversion issues between JDBC and SQL and null versus "false". I suspect you wouldn't see the problem at all if the type was "boolean" instead of "Boolean", but if you need the third state then you may need to experiment to find the SQL type for your particular database vendor/JDBC driver that will cause true/false/null to get handled correctly.


Reid - SCJP2 (April 2002)
Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi,

Please tell me how to deal with field in my Database table with boolean type. I am using postgresql8.0 as Database. & I have coulmn in my table for which I want to set & get values as "true"/"false".
But when i m writing for getters n setters for this boolean field in My CMP EJB class as follows:-
=============================
/**
* @ejb.interface-method view-type = "both"
* @ejb.persistence column-name = "quoted"
* jdbc-type = "BOOLEAN"
* sql-type = "boolean"
* @return Returns the quoted.
*/
public boolean getQuoted() {
return quoted;
}

/**
* @ejb.interface-method view-type = "both"
* @param quoted The quoted to set.
*/
public void setQuoted(boolean quoted) {
this.quoted = quoted;
}

===============================

After Deploying this bean when I m trying to run client on it, it gives me error like:-
==================================

java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
java.lang.ClassNotFoundException: org.postgresql.util.PSQLException (no security manager: RMI class loader disabled)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:217)...............
....................
==================================

Please tell me how should I manage this boolean field???

Also When I m trying to deploy bean without boolean field included in it, It works fine with data gets inserted into database. But Problem comes after boolean field included into Bean.

Please help me. I am trying to solve this since last three days.

Thanx in advance .
Prash
Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
I'm having the same problem with JBoss 4.02. I have tried an accessor of isQuoted() (as the Java Beans spec notes) and getQuouted() as suggested by http://www.coredevelopers.net/library/jboss/cmp/cmp-field.jsp

EJB Doclet doesn't seem to be playing nice right now either.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to manage CMP field with Boolean type????