EJB Best Practives: Objects or Primitives?

I'm trying to understand which is the better option when developing EJB's (CMP and BMP). It makes sense to keep the primary key an object, but will using primitives for other fields affect performance as such?
Up until now I've been pretty much in a habit of using Objects (java.lang.*) as field types.
Anthony

Primitives might make you code more leanly (?) - but there should be no difference as your other types will be serializable which just converts them into bytes, which a primitive really is anyway - just a smaller number of bytes.

Similar Messages

  • Advantages of using ejb vs java objects for pipeline components?

    hi,
    one of our applications is a fairly simple application. for simplicity sake, we are considering using java objects (accessing database tables) instead of ejbs for our pipeline components.
    before flying with this decision, we'd like to be sure we are not missing something obvious.
    please send me any references/pointers you have that summarize what the advantages of one approach (ejb vs java objects) over the other are.
    thanks!

    Wole, you will get a much better response posting this to
    weblogic.developer.interest.ejb newsgroup.
    Joseph Nguyen
    BEA Support
    "Wole Bankole" <[email protected]> wrote in message
    news:3c9a6a1a$[email protected]..
    hi,
    one of our applications is a fairly simple application. for simplicitysake, we are considering using java objects (accessing database tables)
    instead of ejbs for our pipeline components.
    >
    before flying with this decision, we'd like to be sure we are not missingsomething obvious.
    >
    please send me any references/pointers you have that summarize what theadvantages of one approach (ejb vs java objects) over the other are.
    >
    thanks!

  • BMP question : got javax.ejb.EJBException error Object state not saved

    Could anybody please help me? I could not figure out what i did wrong.
    I got the javax.ejb.EJBException error: Object state not saved
    when i test the getname() method for findByPrimaryKey() and findAll() methods.
    Here is my code:
    package org.school.idxc;
    import javax.sql.*;
    import javax.naming.*;
    import javax.ejb.*;
    import javax.sql.*;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Enumeration;
    import java.util.Vector;
    * Bean implementation class for Enterprise Bean: status
    public class statusBean implements javax.ejb.EntityBean {
         private javax.ejb.EntityContext myEntityCtx;
         private int id;
         private String name;
         private DataSource ds;
         private String dbname = "jdbc/idxc";
         private Connection con;
         * ejbActivate
    public void ejbActivate() {
         * ejbLoad
         public void ejbLoad() {
         System.out.println("Entering EJBLoad");
         try
         Integer primaryKey = (Integer) myEntityCtx.getPrimaryKey();
         String sqlstmt = "select id, name from from status where id =?";
         con = ds.getConnection();
         PreparedStatement stmt = con.prepareStatement(sqlstmt);
         stmt.setInt (1,primaryKey.intValue());
         ResultSet rs = stmt.executeQuery();
         if (rs.next())
              this.id = rs.getInt(1);
              this.name = rs.getString (2).trim();
              stmt.close();
         } // if
         else
              stmt.close();
              throw new NoSuchEntityException ("Invalid id " + id);
         }// else
              } // try
         catch (SQLException e)
         System.out.println("EJBLOad : " + e.getMessage());
              } // catch
         finally
         try
              if (con != null)
              con.close();
              }// try
         catch (SQLException e)
              System.out.println("EJBLOad finally" + e.getMessage());
              } // catch
              }// finally
         * ejbPassivate
         public void ejbPassivate() {
         * ejbRemove
         public void ejbRemove() throws javax.ejb.RemoveException {
         System.out.println ("Entering ejb Removed");
         try
         String sqlstmt = "delete from status where id=" + id;
         con = ds.getConnection();
         Statement stmt = con.createStatement();
         stmt.executeUpdate(sqlstmt);
         stmt.close();
         }// try
         catch (SQLException e)
         System.out.println("Ejb Remove" + e.getMessage());     
         } // catch
         finally
         try
              if (con!=null)
                   con.close();
         }// try
         catch (SQLException e)
              System.out.println ("EJBRemoved " + e.getMessage());
         } // catch
         } // finally
         * ejbStore
         public void ejbStore() {
         System.out.println("Entering the ejbStore");
         try
    String sqlstmt = "update status set id=" + id + ",name='" + name + "' where id=" + id;
         con = ds.getConnection();
         Statement stmt = con.createStatement();
         if (stmt.executeUpdate(sqlstmt) != 1)
              throw new EJBException ("Object state not saved");
    stmt.close();     
         } // try
         catch (SQLException e)
              System.out.println ("EJBStore : " + e.getMessage());
         }// catch
         finally
         try
              if (con != null)
              con.close();
         } // try
         catch(SQLException e)
              System.out.println ("EJBStore finally " + e.getMessage());
         } // catch
         } // finally
         * getEntityContext
         public javax.ejb.EntityContext getEntityContext() {
              return myEntityCtx;
         * setEntityContext
         public void setEntityContext(javax.ejb.EntityContext ctx) {
              myEntityCtx = ctx;
              try
              InitialContext initial = new InitialContext();
              ds = (DataSource)initial.lookup(dbname);
    } // try
              catch (NamingException e)
              throw new EJBException ("set Entity context : Invalid database");     
              }// catch
         * unsetEntityContext
         public void unsetEntityContext() {
              myEntityCtx = null;
         * ejbCreate
         public Integer ejbCreate(Integer key, String name) throws javax.ejb.CreateException {
    this.id = key.intValue();
    this.name = name;
              System.out.println ("Entering ejbCreated!!!");
              try
              String sqlstmt = "insert into status(id,name) values (" + id + ",'" + (name == null ? "" : name) + "')";
              con = ds.getConnection();
              Statement stmt = con.createStatement();
              stmt.executeUpdate(sqlstmt);
              stmt.close();
              }// try
              catch (SQLException e)
              System.out.println("EJBCreate : SQLEXception ");     
              }// catch
              finally
              try
              if (con!=null)
                   con.close();
              }// try
              catch (SQLException e)
              System.out.println ("EJB Created Finally : SQLException");
              e.getMessage();
              } // catch
              }// finally
              this.id = key.intValue();
              this.name = name;
              return key ;
         * ejbPostCreate
         public void ejbPostCreate(Integer id, String name) throws javax.ejb.CreateException {
         * ejbFindByPrimaryKey
         public Integer ejbFindByPrimaryKey(
              Integer key) throws javax.ejb.FinderException {
              try
              String sqlstmt = "select id from status where id=" + key.intValue();
              con = ds.getConnection();
              Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(sqlstmt);
              if (!rs.next())
              throw new ObjectNotFoundException();     
              } // if
              rs.close();
              stmt.close();
              } // try
              catch (SQLException e)
              System.out.println ("EJBFindBYPrimaryKey " + e.getMessage());     
              } // catch
              finally
              try
              if (con!=null)
                   con.close();
              }// try
              catch (SQLException e)
              System.out.println ("EJB Find by primary key" + e.getMessage());
              }// catch
              }// finally
              return key;
         * @return Returns the name.
         public String getName() {
              return this.name;
         * @return Returns id
         public int getId() {
              return this.id;
         * @param name The name to set.
         public void setName(String xname) {
              this.name = xname;
         * ejbFindByLastnameContaining
         public Enumeration ejbFindAllNamne () throws javax.ejb.FinderException
         try
         String sqlstmt = "select id from status order by id";
         con = ds.getConnection();
         Statement s = con.createStatement();
         ResultSet rs = s.executeQuery(sqlstmt);
         Vector keys = new Vector();
         while (rs.next())
              keys.add(new Integer(rs.getInt(1)));
         }// while
         rs.close();
         s.close();
         con.close();
         return keys.elements();
         } // try
         catch (SQLException e)
              throw new FinderException (e.toString());
         } // catch
    }

    Hi,
    if you look at your error message you will see the problem. In your code you've missed to implement
    public void ejbPassivate {}
    so your code looks like this
    import java.lang.Object;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.rmi.RemoteException;
    import java.lang.Math;
    import java.util.Random;
    import java.io.*;
    /** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: * @author * @version 1.0 */
    public class DiceEJB implements SessionBean, Serializable
         public int[] Roll()
              Random rng = new Random();
              int[] diceArray = new int[5];
              for(int i =0; i < diceArray.length;i++)
                   diceArray[i] = (Math.abs (rng.nextInt()) % 6) +1;
              return diceArray;
         public DiceEJB(){}
         public void ejbCreate() {}
         public void ejbRemove() {}
         public void ejbActivate() {}
         public void ejbPassivate() {}
         public void setSessionContext (SessionContext sc)
         private void writeObject(ObjectOutputStream oos) throws IOException
              oos.defaultWriteObject();
         private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException
              ois.defaultReadObject();
    bye

  • Error converting j2EE-Specific ejb xml to object representation

    I am trying to webservice using Sun one. I got four entity beans and two sessions. I exposed the business of the session beans as webservice function.
    I tested the individual sesion beans they are working fine.
    When I created a webservice, and when I am trying to deploy the web service the follwing error occured.
    I tried to run the verrfier tool, but is not loading the file...it s getting stucked up.
    Here,
    BSApp -- J2ee application in which webservice is included
    BSManagerContrl --- is one of the two session bean which i created
    Book -- is the entity bean
    I also checked the module of the session bean to verify whether i included the Book enity bean or not. Other wise I would i successfully tested the session bean.
    Thank you
    [b][b]Deployment Error -- Error while running ejbc -- Fatal Error from EJB Compiler -- Failed to load
    deployment descriptot for BSApp
    Cause: Error converting j2EE-Specific ejb xml to object representation
    BSManagerContrl_EJBModule.jar
    app_BSApp BSManagerContrl_EJBModule
    Referencing error: This bundle has no bean of name [Book]
    <ejb><ejb-name>Book</ejb-name><jndi-name>ejb/Book</jndi-name><pass-by-refernece>false</pass-by-reference><cmp><mapping-properties>

    Hi parsuram,
    Its not coming up anymore. All i did was re-map the table under Sun AS Mappings under properties for the EJBModule. Its really strange. Thanks a lot for your concern. I really appreciate it.

  • ANN: Eclipse EJB 3.0 Object-Relational Mapping Project Requirements posted

    A document that presents an intitial feature and use case list for the early milestones of the Eclipse EJB 3.0 Object/Relational Mapping project has been posted to the project newsgroup (news://news.eclipse.org/eclipse.technology.ejb-orm). It also demonstrates a set of user interface components for editing EJB 3.0 Entities. The document covers the basics and is designed to illustrate the concept. It is in no way comprehensive. For example, it doesn't thoroughly cover the editing of ORM xml descriptors although this is an important requirement for the project. ORM xml support will be detailed in coming revisions, and slated for future milestones.
    The purpose of this document is to invite comment on the approach. If you are interested in EJB 3.0 Entity support in Eclipse please give the doc a look over and post your feedback to the EJB 3.0 Object-Relational Mapping Project newsgroup.
    Newsgroup: news://news.eclipse.org/eclipse.technology.ejb-orm
    Simple Web Interface http://www.eclipse.org/newsportal/thread.php?group=eclipse.technology.ejb-orm
    --Shaun Smith
    Project Overview:
    The goal of this project is to add comprehensive support to the Eclipse Project for the definition and editing of Object-Relational (O/R) mappings for EJB 3.0 Entity Beans. EJB 3.0 O/R mapping support will focus on minimizing the complexity of mapping by providing creation and automated initial mapping wizards, and programming assistance such as dynamic problem identification. The implementation will be extensible so third party vendors can add to its functionality.
    Project Proposal:
    http://www.eclipse.org/proposals/eclipse-ejb30-orm/index.html

    A document that presents an intitial feature and use case list for the early milestones of the Eclipse EJB 3.0 Object/Relational Mapping project has been posted to the project newsgroup (news://news.eclipse.org/eclipse.technology.ejb-orm). It also demonstrates a set of user interface components for editing EJB 3.0 Entities. The document covers the basics and is designed to illustrate the concept. It is in no way comprehensive. For example, it doesn't thoroughly cover the editing of ORM xml descriptors although this is an important requirement for the project. ORM xml support will be detailed in coming revisions, and slated for future milestones.
    The purpose of this document is to invite comment on the approach. If you are interested in EJB 3.0 Entity support in Eclipse please give the doc a look over and post your feedback to the EJB 3.0 Object-Relational Mapping Project newsgroup.
    Newsgroup: news://news.eclipse.org/eclipse.technology.ejb-orm
    Simple Web Interface http://www.eclipse.org/newsportal/thread.php?group=eclipse.technology.ejb-orm
    --Shaun Smith
    Project Overview:
    The goal of this project is to add comprehensive support to the Eclipse Project for the definition and editing of Object-Relational (O/R) mappings for EJB 3.0 Entity Beans. EJB 3.0 O/R mapping support will focus on minimizing the complexity of mapping by providing creation and automated initial mapping wizards, and programming assistance such as dynamic problem identification. The implementation will be extensible so third party vendors can add to its functionality.
    Project Proposal:
    http://www.eclipse.org/proposals/eclipse-ejb30-orm/index.html

  • Best List object

    can any one please guide me to know which one is the best list object to show a table of data in the jsp?

    nothing on paper. But from personal experience I know that Vector can be an order of magnitude or more slower than ArrayList.
    Had a servlet that used Vectors heavily. It was slow. Moving to ArrayLists for the implementation increased performance from something like 10 seconds per call to under 1 second. Same hardware, same request, same result.

  • Looking up an EJB – best practices

    Hi, what's the correct way to specify an EJB when attempting to get
    the home interface?
    Using WebLogic, it seems people just specify the JNDI name and it
    seems to work fine.
    Object ref = context.lookup("testsession");
    But other times I see this syntax:
    Object ref = context.lookup("java:comp/env/ejb/MySession2");
    Which method is best practices?
    Thanks

    Hello Marcus,
    Actually, EJB 1.1 introduced a formal manner to specify the location of the EJBs,
    namely the
    "java:comp/env/ejb" location. This is actually a best practice for specifying
    the location of
    your EJBs, because the "application assembler" doesn't need to know exactly what
    the JNDI
    name of the particular EJB is. This task is left to the actual deployer. If you
    use the actual JNDI
    name of the EJB instead of Sun's recommended prefix, then you are limiting the
    overall portability
    of the EJBs, because the code must be modified to reflect the exact JNDI name
    that will be used
    based on the particular J2EE application server that they are being deployed on.
    You can read up about this in chapter 14 of the EJB 1.1 specification as well
    as chapter 5 of the
    J2EE 1.2 specification. Also, check out Mastering Enterprise JavaBeans 2nd Edition
    by
    Ed Roman, Scott W. Ambler, and Tyler Jewell for more explanation and code examples.
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    [email protected] (Marcus Leon) wrote:
    Hi, what's the correct way to specify an EJB when attempting to get
    the home interface?
    Using WebLogic, it seems people just specify the JNDI name and it
    seems to work fine.
    Object ref = context.lookup("testsession");
    But other times I see this syntax:
    Object ref = context.lookup("java:comp/env/ejb/MySession2");
    Which method is best practices?
    Thanks

  • EJB and Oracle9i Object Relational Features

    Hy,
    Somebody knows where is some information (pdf, html, anything) about work with EJB to load and manipulate the new oracel9i object realtional features (nested tables, varrays, ref, ...)????
    Thanks

    Fernando -- At this time the best way to work with the object-relational features is with BMP. Some of those capabilities can be used with TopLink as well. Lastly, we are looking at how best to leverage these in the future.
    Thanks -- Jeff Schafer

  • Best Practive to resturn Resultset to a JSP page

    I'm writing a class to return a resultSet to use in a JSP page or at least i think thats what i want to do. Whats the best practice to return that resultset.....As the class is written below, when i try to iterate through the resultset in the jsp page i get a NullPointerException which i understand because i closed the connection before returning....If i take out all the code in the finally section i can iterate through the data no problem....but thats not good to leave connections open.......instead of returning a resultset should i return some other type such as an Array with all the data. How should i return the data?
    ======================================================================
    package foo;
    import javax.naming.*;
    import javax.sql.*;
    import java.sql.*;
    public class DBTest{
    String foo = "Not Connected";
    String bar = "Not";
    public ResultSet getUser(){
    Connection conn = null;
    Statement stmt = null; //Or preparedStatement if needed
    ResultSet rs = null;
    try{
    Context ctx = new InitialContext();
    if(ctx == null)
    throw new Exception("Boom - No Context");
    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/Show");
    if(ds != null){
    conn = ds.getConnection();
    if(conn != null){
    foo = "Got Connection " + conn.toString();
    stmt = conn.createStatement();
    rs = stmt.executeQuery("SELECT * FROM user");
    if(rs.next()){
    foo=rs.getString("login");
    bar=rs.getString("password");
    }catch(Exception e){
    e.printStackTrace();
    }finally{
    // Always make sure result sets and statements are closed,
    // and the connection is returned to the pool.
    if(rs != null){
    try{
    rs.close();
    }catch(SQLException e){;}
    rs=null;
    if(stmt != null){
    try{stmt.close();}catch(SQLException e){;}
    stmt=null;
    if(conn != null){
    try{conn.close();}catch(SQLException e){;}
    conn=null;
    return rs;
    public String getFoo(){return foo;}
    public String getBar(){return bar;}

    Yes, when you close your connection all data in your result set is lost, and yes its not a good idea to keep connections open. Its also not a good idea to pass results around. What you should do is store the data in some type of collection object and pass that to your jsp.
    for exmaple if you select data from a table that stores names of people, e.g. two columns first_name and last_name, then create a class called People with two private string members to hold the first and last names. loop through your result set and build a People object for each row of data. when your done close the result set (and the connection if you want). store all your People objects is a collection (vector, array, whatever). pass the vector to your jsp for display.
    -S-

  • Mapping objects to primitives

    Say I have a class called Registrant, and a Registrant can be registered for one or more meetings. Meetings are stored in the class Meeting. Depending on whether or not they are a student and on the time that they register, each registrant pays a different fee to register for a given Meeting. Because of the requirements of the application, it needs to be possible to determine how much money a Registrant paid when they registered for a Meeting. The quickest solution to this seemed to be to have a Map<Meeting, Double> which would store how much a Registrant paid when they registered for the Meeting.
    The problem that arose, however, was that the application in question used the Java Persistence API, which doesn't permit Lists/Sets/Maps of primitives. Because the project had been for a class and I needed to get it done, I implemented a somewhat hacky solution wherein there was a function that calculated how much a Registrant had paid by passing the date they registered to the Meeting class, which in turn would re-calculate how much someone registering on that date would have paid. However, I didn't like this solution at all, partly because the code wasn't intuitive, and partly because it wasted time re-calculating the fees every single time it wanted to reference or display registration information.
    What should I have done here? Should I have created a class called Fee that contained the amount and date of payment, and then mapped Meetings to Fees in the Registrant class?

    Why don't you use Wrapper classes?
    For example, to store the fee (assuming it is double value), you can use java.lang.Double class.
    One of the constructor of Double can take double value as argument and you can store the object in Map.
    For example, the following example may solve your problem.
    // Meeting class
    public class Meeting{
    private java.lang.String rname;
    public Meeting(java.lang.String mname){
    this.mname = mname;
    // Registrant class
    public class Registrant{
    private int sno;
    private java.lang.String rname;
    java.util.Map<java.util.HashMap, java.lang.Double>;
    public Registrant(int sno, java.lang.String rname){
    this.sno = sno;
    this.rname = rname;
    feesMap = new java.util.HashMap<java.util.HashMap, java.lang.Double>();
    public void attendMeeting(Meeting m, double fees){
    feesMap.put(m, new java.lang.Double(fees));
    // Main class
    public class AttendMeeging{
    public AttendMeeting(){
    Registrant registrant = new Registrant(1, "Registrant1");
    Meeting meeting = new Meeting("Meeting1");
    registrant.attendMeeting(meeting, 10.0);
    }Hope this helps.

  • Exception when invoking create method on entity ejb's home object

    I have a simple entity bean. I am able to get the reference to the entity's home object. But when I run create method on entity's home interface, I get the following exception. The create method takes no arguments as the primary key is Auto-Increment field in MYSQL database. Here is the exception. I am using jdeveloper and embedded OC4J as server.
    07/06/22 15:51:15 java.lang.NullPointerException
    07/06/22 15:51:15 at EmployeeHome_EntityHomeWrapper2.create(EmployeeHome_EntityHomeWrapper2.java:1168)
    07/06/22 15:51:15 at com.pd.EmpAddInput.addEmployee(EmpAddInput.java:64)
    07/06/22 15:51:15 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    07/06/22 15:51:15 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    07/06/22 15:51:15 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    07/06/22 15:51:15 at java.lang.reflect.Method.invoke(Method.java:585)
    07/06/22 15:51:15 at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:146)
    07/06/22 15:51:15 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:92)
    07/06/22 15:51:15 at javax.faces.component.UICommand.broadcast(UICommand.java:332)
    07/06/22 15:51:15 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:287)
    07/06/22 15:51:15 at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:401)
    07/06/22 15:51:15 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:95)
    07/06/22 15:51:15 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:268)
    07/06/22 15:51:15 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
    07/06/22 15:51:15 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
    07/06/22 15:51:15 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:712)
    07/06/22 15:51:15 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:369)
    07/06/22 15:51:15 at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:865)
    07/06/22 15:51:15 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:447)
    07/06/22 15:51:15 at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:215)
    07/06/22 15:51:15 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
    07/06/22 15:51:15 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
    07/06/22 15:51:15 at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
    07/06/22 15:51:15 at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
    07/06/22 15:51:15 at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
    07/06/22 15:51:15 at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
    07/06/22 15:51:15 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
    07/06/22 15:51:15 at java.lang.Thread.run(Thread.java:595)
    What may be causing this exception.

    I have solved the problem. It had to do with the autocommit=true feature of the MYSQL connection. However I have ran into another trouble. I am getting the following exception.
    java.lang.IllegalStateException: Can not call getPrimaryKey() inside ejbCreate(...) methods, the entity does not have an identity yet, see the EJB 2.0 specification chapter 10.5.4
         at com.evermind.server.ejb.EJBUtils.throwGetPrimaryKeyInEJBCreateException(EJBUtils.java:892)
         at EmployeeRemote_EntityBeanWrapper0.getPrimaryKey(EmployeeRemote_EntityBeanWrapper0.java:1686)
         at EmployeeHome_EntityHomeWrapper2.create(EmployeeHome_EntityHomeWrapper2.java:1055)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:53)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    java.lang.IllegalStateException: Can not call getPrimaryKey() inside ejbCreate(...) methods, the entity does not have an identity yet, see the EJB 2.0 specification chapter 10.5.4
         at com.evermind.server.rmi.RMICall.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMICall.java:109)
         at com.evermind.server.rmi.RMICall.throwRecordedException(RMICall.java:125)
         at com.evermind.server.rmi.RMIClientConnection.obtainRemoteMethodResponse(RMIClientConnection.java:517)
         at com.evermind.server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:461)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
         at __Proxy0.create(Unknown Source)
         at com.pd.model.EmployeeRemoteClient.main(EmployeeRemoteClient.java:37)
    I am not calling getPrimaryKey() in ejbCreate() then why this exception

  • Why is the Integer wrapper class object and primitive object equal ?

    This is my code :
    package obectorientation;
    public class oo3 {
         public static void main(String[] args) {
              int x=1; float y=1.0F;
              int x1=1;
                                    Integer y1= new Integer(1);
              if(x1==y1)
                   System.out.println("Equal");
              else
                   System.out.println("NOT Equal");
    O/P : EqualMy question is why are x1 and y1 equal ? Won't y1 be a different object and x1 just a primitive variable ?
    Thanks in Advance.

    Specifically, it's because y1 gets unboxed before the comparison. What's really happening is effectively: if ( x1 == y1.intValue() )

  • Casting Object into primitive

    I'm using java reflection to return value of an attribute from a Class. The attribute is a float primitive. However, the return form is an Object. How do I cast it into the float primitive again?
    Thanks.
    LG

    From the API for Method.invoke: >>if the value has a primitive type, it is first appropriately wrapped in an object<<
    So if the method returns a float primitive, Method.invoke will return a Float object.

  • Create array of arbitrary dimensions / get Class object for primitive types

    Here's an interesting problem: is there any way to code for the creation of an n-dimensional array where n is only known at runtime (input by user, etc.)?
    java.lang.reflect.Array has a newInstance method which returns an array of an arbitrary number of dimensions specified by the int[] argument, which would give me what I want. However, the other argument is a Class object representing the component type of the array. If you want to use this method to get an array of a primitive type, is it possible to get a Class object representing a primitive type?

    That doesn't help, since the whole problem is that the number of dimensions aren't known until runtime. You can't simply declare a variable of type int[][] or use an int[][] cast, since the number of []'s is variable.
    The int.class construction was partly what I was looking for. This returns the array needed (assuming some read method):
    int dimensions = read();
    int size = read();
    int[] index = new int[dimensions];
    for (int i = 0; i < dimensions; i++)
        index[i] = size;
    Object myArray = Array.newInstance(int.class, index);The only problem is, as an Object, I can't use myArray usefully as an array. And I can't use a cast, since that requires a fixed number of dimensions.

  • Arrays of arbitrary dimensions / Class object for primitive types

    Here's an interesting problem: is there any way to code for the creation of an n-dimensional array where n is only known at runtime (input by user, etc.)?
    java.lang.reflect.Array has a newInstance method which returns an array of an arbitrary number of dimensions specified by the int[] argument, which would give me what I want. However, the other argument is a Class object representing the component type of the array. If you want to use this method to get an array of a primitive type, is it possible to get a Class object representing a primitive type?

    Devil is in the detailspublic class Test2 {
      public static void main(String[] args) {
        Object[] myArray = new Object[10];
        fillDimensionalArray(myArray, 5, 5);
      public static void fillDimensionalArray(Object[] array, int dim, int size) {
        if (dim==1) {
          for (int i=0; i<size; i++) {
            array[i] = new int[size];
            for (int j=0; j<size; j++) ((int[])array)[j]=999;
    } else {
    for (int i=0; i<array.length; i++) {
    array[i] = new Object[size];
    for (int j=0; j<size; j++) {
    fillDimensionalArray( (Object[]) array[i], dim - 1, size);

Maybe you are looking for

  • Firefox won't open new tabs when I click, also he doesn't open new tabs when I use CTRL+T. Any solutions?

    When I want to open a new tab, firefox doesn't do it. The problem is the same when I use CTRL+T. So I can't open any new tabs. Nothing seems to work: restart the pc, closing firefox,...

  • Creation of  RFC

    Hi Guys, Please help me  presently working on creation  of  RFC, front end using EP.  Using this RFC update the 4 databse tables. Export Parameters of RFC give one of the databse table fields. in TABLE  type  database table. what ever i am declaring 

  • BPM - Exception not thrown

    Hi , I created a BPM in which I I have Receive Step -> Send Step -> Block Step -> Block Processing branch - Receive Step ->Send Step Block Dead Line Branch - Dead line of 1 minute and Control step for raising exception Block Exception handler branch

  • Mail Messages arrive then disappear.

    My emails are being pushed to my 3g iPhone but they almost immediately disappear from my Inbox. Any solutions?

  • Problem about jtable and database

    The problem is that when i clicked the button to save the values of textfields and text area, although the table is supposed to show the new list of datas from the db, it adds the new data list to the end of the first list. I have to list one old and