Bigdecimal as PrimaryKey Type in Entity

Hi,
   I am using Netweaver CE 7.1 for deploying a test application. My Entity has a Bigdecimal field as Primary key. While deploying the applcation I am getting following exception :
<b>
Primary Keys Check: Primary key 'actRmatId' of class 'entity.Activities' cannot be of type 'java.math.BigDecimal'. Allowed types are: Java primitive types; any primitive wrapper type; java.lang.String; java.util.Date; java.sql.Date; byte[], file: TestEJB.jar#META-INF/persistence.xml, column 0, line 0, severity: error</b>
  Can anybody please tell me, why Bigdecimal is restricted in this version of netweaver while it was working fine in NetWeaver Application Server, Java(TM) EE 5 Edition...
  My Application is using Bigdecimal because of the precision requirements. Is there a way to use Entities with Bigdecimal  as primary key types in CE7.1.
Thanks ,
Prasoon.

Hi Prasoon,
with CE 7.1, we introduced a check that asserts that the IDs obey the +recomendations +expressed by the JPA specification § 2.1.4:
+The primary key (or field or property of a composite primary key) should be one of the following types:
any Java primitive type; any primitive wrapper type; java.lang.String; java.util.Date;
java.sql.Date. In general, however, approximate numeric types (e.g., floating point types) should
never be used in primary keys. Entities whose primary keys use types other than these will not be portable.
If generated primary keys are used, only integral types will be portable. If java.util.Date is
used as a primary key field or property, the temporal type should be specified as DATE.+
This check rejects BigDecimal fields. It is probably to strict. We will likely lift the restriction with the next release.
Unfortunately, I am not aware of any workaround to disable the check.
Best regards,
Adrian Görler

Similar Messages

  • TOPLINK-38 ClassCastException if specifying toplink.cache.type. ENTITY

    Some background info:
    I am running a 10.1.3.3 OC4J standalone. On the same instance there is a resource adapter also using toplink JPA and get the entity manager from the factory instead of the container managed one. In my application, I also use an application managed EM. When deploying by myself, there is not issue. When it is deployed with the resource adapter, I would get the ClassCastException.
    If I removed the properties in the persistence.xml file that contains the "toplink.cache.type.<ENTITY>", the exception goes away and everything works fine. Following is my persistence.xml file.
    <persistence-unit name="oc4j" transaction-type="JTA">
    <provider>
    oracle.toplink.essentials.PersistenceProvider
    </provider>
    <jta-data-source>java:jdbc/OcmsXdmsDs</jta-data-source>
    <class>oracle.sdp.xcapdatamodel.jpa.XCAPAppUsage</class>
    <class>oracle.sdp.xcapdatamodel.jpa.XCAPUser</class>
    <class>oracle.sdp.xcapdatamodel.jpa.XCAPDocument</class>
    <class>oracle.sdp.xcapdatamodel.jpa.AppUsageSchema</class>
    <properties>
    <property name="toplink.session-name" value="xdms-multinode-session"/>
    <property name="toplink.logging.level" value="INFO"/>
    <!-- Optimize toplink caching -->
    <property name="toplink.cache.type.XCAPUser" value="None"/>
    <property name="toplink.cache.type.XCAPDocument" value="None"/>
    <property name="toplink.cache.type.XCAPAppUsage" value="Full"/>
    <property name="toplink.cache.type.AppUsageSchema" value="Full"/>
    </properties>
    </persistence-unit>

    Exception [TOPLINK-38] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.except
    ions.DescriptorException
    Exception Description: Identity map constructor failed because an invalid identity map was specified.
    Internal Exception: java.lang.ClassCastException: oracle.toplink.essentials.internal.identitymaps.FullIdentityMap
    Descriptor: RelationalDescriptor(oracle.sdp.xcapdatamodel.jpa.AppUsageSchema --> [DatabaseTable(APPUSAGESCHEMA)])
    at oracle.toplink.essentials.exceptions.DescriptorException.invalidIdentityMap(DescriptorException.java:778)
    at oracle.toplink.essentials.internal.identitymaps.IdentityMapManager.buildNewIdentityMap(IdentityMapManager.jav
    a:293)
    at oracle.toplink.essentials.internal.identitymaps.IdentityMapManager.getIdentityMap(IdentityMapManager.java:716
    at oracle.toplink.essentials.internal.identitymaps.IdentityMapManager.acquireDeferredLock(IdentityMapManager.jav
    a:119)
    at oracle.toplink.essentials.internal.sessions.IdentityMapAccessor.acquireDeferredLock(IdentityMapAccessor.java:
    85)
    at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:479)
    at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java
    :451)
    at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:421)
    at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:387)
    at oracle.toplink.essentials.queryframework.ReportQueryResult.processItem(ReportQueryResult.java:220)
    at oracle.toplink.essentials.queryframework.ReportQueryResult.buildResult(ReportQueryResult.java:182)
    at oracle.toplink.essentials.queryframework.ReportQueryResult.<init>(ReportQueryResult.java:98)
    at oracle.toplink.essentials.queryframework.ReportQuery.buildObject(ReportQuery.java:594)
    at oracle.toplink.essentials.queryframework.ReportQuery.buildObjects(ReportQuery.java:643)
    at oracle.toplink.essentials.queryframework.ReportQuery.executeDatabaseQuery(ReportQuery.java:804)
    at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
    at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:692)
    at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:7
    46)
    at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
    at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
    at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:924)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:367)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:478)
    at oracle.sdp.xcapconfigmanager.JPAApplicationUsageImpl.loadXmlXsd(JPAApplicationUsageImpl.java:203)
    at oracle.sdp.xcapconfigmanager.XCAPConfigManager.loadJPAAppUsage(XCAPConfigManager.java:447)
    at oracle.sdp.xcapconfigmanager.XCAPConfigManager.loadApplicationUsages(XCAPConfigManager.java:402)
    at oracle.sdp.xcapconfigmanager.XCAPConfigManager.start(XCAPConfigManager.java:366)
    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 oracle.sdp.jmxframework.ModelerBeanDeployer.invokeLifeCycleOperation(ModelerBeanDeployer.java:315)
    at oracle.sdp.jmxframework.ModelerBeanDeployer.startService(ModelerBeanDeployer.java:266)
    at oracle.sdp.jmxframework.ModelerBeanDeployer.initializeServices(ModelerBeanDeployer.java:359)
    at oracle.sdp.jmxframework.ModelerBeanDeployer.preRegister(ModelerBeanDeployer.java:384)
    at com.sun.jmx.mbeanserver.BaseMetaDataImpl.preRegisterInvoker(BaseMetaDataImpl.java:83)
    at com.sun.jmx.mbeanserver.MetaDataImpl.preRegisterInvoker(MetaDataImpl.java:237)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:923)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:337)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:497)
    at oracle.oc4j.admin.jmx.server.state.ApplicationStateFilterMBeanServer.registerMBean(ApplicationStateFilterMBea
    nServer.java:349)
    at com.evermind.server.Application.registerApplicationMBeans(Application.java:2978)
    at com.evermind.server.Application.addJ2EEApplicationMBean(Application.java:1682)
    at com.evermind.server.ApplicationStateRunning.initializeApplication(ApplicationStateRunning.java:201)
    at com.evermind.server.Application.setConfig(Application.java:438)
    at com.evermind.server.Application.setConfig(Application.java:339)
    at com.evermind.server.ApplicationServer.addApplication(ApplicationServer.java:1895)
    at com.evermind.server.ApplicationServer.initializeDeployedApplications(ApplicationServer.java:1651)
    at com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:1034)
    at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:131)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: java.lang.ClassCastException: oracle.toplink.essentials.internal.identitymaps.FullIdentityMap
    at oracle.toplink.essentials.internal.identitymaps.IdentityMapManager.buildNewIdentityMap(IdentityMapManager.jav
    a:289)

  • Type 4 entity as Search Result

    We are using MDG 7.0 version.
    We have a requirement to display the Type 4 entity instances in the search view.
    On selecting one of the instance of Type 4 we need to use the Type 1 entity as part of the change request.
    Can anyone please revert me back as soon as possible.

    Hi Naveen
    As per  SAP we can create search help only for Type1 entity type

  • Calling Oracle stored procedure with out param of user define type from Entity Framework 5 with code first

    Guys i am using Entity Framework 5 code first (I am not using edmx) with Oracle and all works good, Now i am trying to get data from stored procedure which is under package but stored procedure have out param which is user define type, Now my question is
    how i will call stored procedure from entity framework
    Thanks in advance.

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • Assigning format/format type to entity or view attribute

    When I edit a entity or view attribute and click on the Control Hints node, the Format and Format Type fields are disabled.
    The online help mentions "mapping of the domain type to it’s available formatters" but in this particular instance I am not using a domain type.
    Does the attribute have to be of a domain type in order to specify a format type and format for that attribute?

    It looks like the attribute formatting only works for numbers and dates. I was trying to apply the formatting to a string (social security number).
    Still not sure if this is a bug or by design.

  • Boolean types with entity framework code first and oracle provider

    Working in a application that has to work in oracle and sqlServer. In SqlServer we have used "Bit" to store booleans and in oracle number(1).
    Have check other threads in this forum, but didnt find any that fix my problem, sorry if this may have been discused before.
    We have created a code first model were we find few bool properties mapped to database fields.
    for example:
    public partial class ZPruebaBooleano
    public int Numero { get; set; }
    public bool Booleano { get; set; }
    Mapped as:
    this.ToTable("ZPRUEBABOOLEANO", schema);
    this.HasKey<int>(t => t.Numero);
    this.Property(t => t.Numero).HasColumnName("NUMERO");
    this.Property(t => t.Booleano).HasColumnName("BOOLEANO");
    Also, sw added to the application configuration file (for simplicity we have test it without the use of any additional dll):
    <oracle.dataaccess.client>
    <settings>
    <add name="bool" value="edmmapping number(1,0)" />
    <add name="byte" value="edmmapping number(3,0)" />
    <add name="int16" value="edmmapping number(4,0)" />
    <add name="int32" value="edmmapping number(9,0)" />
    <add name="int64" value="edmmapping number(18,0)" />
    </settings>
    </oracle.dataaccess.client>
    I am confident that the provider factory read it when creating the model, because it provokes an exception if i add an invalid entry in any of the type names mapped in the file.
    As i have find in other forums, this should work. But now i am not sure if should work always, including code first.
    I have this exception when i excecute the code (translated from spanish, sorry for any mistake):
    Type 'Edm.Boolean[Nullable=False,DefaultValue=]' from 'Booleano' to type'PruebaBooleanos.ZPruebaBooleano' is not compatyble with 'OracleEFProvider.number[Nullable=False,DefaultValue=,Precision=38,Scale=0]'
    Its funy that says Precision=38. The database is Number(1), i am sure about that, in fact this is the script:
    CREATE TABLE ZPRUEBABOOLEANO
    NUMERO NUMBER(15),
    BOOLEANO NUMBER(1)
    Also, i find it interesting that i was having this mistake even when i was not informing the table i was maping, like if the oracle provider didnt even check if the column was number(anything). Right now is well maped, table and schema.
    I have test to create an integer property wrapped by the boolean one, as we can see in this code.
    namespace PruebaBooleanos
    public partial class ZPruebaBooleano
    public int Numero { get; set; }
    public bool Booleano
    get
    return iBooleano == 1 ? true : false;
    set
    iBooleano = value ? 1 : 0;
    public int iBooleano { get; set; }
    in this last case i ignored the boolean and mapped the integer.
    That worked ok in oracle. But added 2 problems:
    1. It fails in SqlServer, because in sql server is bit
    2. Cant query the entity model using the boolean property as it is not maped to Database.
    I could change the bit field in SqlServer to Number.
    But i would like to keep bit in sqlserver and number(1) in oracle.
    Anyone had a similar problem?
    I am open to any ideas, thanks !!!
    libo

    It's cool. :)
    Sure. I can upload an EDMX file that works against my database if you want to look at it. The relevant parts are probably much like you'd expect. I've removed some columns from this version to make it easier to read.
    From the SSDL:
            <EntityType Name="PARAMETER">
              <Key>
                <PropertyRef Name="PARAMETER_CD" />
              </Key>
              <Property Name="PARAMETER_CD" Type="number" Nullable="false" Precision="4" />
              <Property Name="PARAMETER_ACTIVE_INDR" Type="number" Nullable="false" Precision="1" />
            </EntityType>From the CSDL:
    <EntityType Name="PARAMETER">
              <Key>
                <PropertyRef Name="PARAMETER_CD" />
              </Key>
              <Property Type="Int16" Name="PARAMETER_CD" Nullable="false" />
              <Property Type="Boolean" Name="PARAMETER_ACTIVE_INDR" Nullable="false" />
            </EntityType>From the C-S mapping:
    <EntitySetMapping Name="PARAMETER">
                <EntityTypeMapping TypeName="Model.PARAMETER">
                  <MappingFragment StoreEntitySet="PARAMETER">
                    <ScalarProperty Name="PARAMETER_ACTIVE_INDR" ColumnName="PARAMETER_ACTIVE_INDR" />
                    <ScalarProperty Name="PARAMETER_CD" ColumnName="PARAMETER_CD" />
                  </MappingFragment>
                </EntityTypeMapping>
              </EntitySetMapping>Also worth noting that the EDMX mapper probably won't set the provider and token correctly:
    <Schema Namespace="Model.Store" Alias="Self" Provider="Oracle.DataAccess.Client" ProviderManifestToken="11.2" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">Full version is available at http://www.hiredgoons.ca/DataImport.edmx . This is an early development one so I make no apologies for not renaming columns to something readable. ;) It does work correctly as I've had it in testing (taking data from a 170MB excel file and putting it into Oracle using the model). It was created using DB First.
    When you have it load at runtime, you need the application configuration settings to map bool to number(1). If that's in app.config or web.config it'll pick it up. Probably worth noting that if you don't have the configuration setting and you load this, the model doesn't validate correctly. As soon as you try to create a DbContext from it, you get an immediate exception that number(1) doesn't map to boolean.
    Edited by: Tridus on Nov 21, 2012 3:37 PM

  • How to reference a pre-defined table type in entity definition

    I have a Table Type brc.sapere.gso.DDL::domain.TIME_PERIOD defined.
    I try to use it in an entity definition. (dbcommon.hdbdd is attached.)
    But there is an error saying
    ERROR      brc/sapere/gso/DDL/dbcommon.hdbdd
               CDS activation failed;Full qualified names are not allowed
    How can I reference the table type?

    Kalhari wrote:
    Hi, Thanks, but I've seen this. What I need to know is if there is a way to map "user defined table type" specifically, which is a new SQL type introduced with SQL 2008.1. Depends on the database.
    2. Depends on the JDBC driver
    3. Depends on JDBC spec that it being used.

  • How to Programmatically Find the PrimaryKey Of An Entity?

    Hello !
    Is it possible to find, programmatically, which property is the primary key of an entity?
    Best regards,
    Ciro

    you are not on an entity but on a entity collection.
    check this article where I use the above:
    http://blog.pragmaswitch.com/?p=291
    paul van bladel ==independent enterprise application architect== http://blog.pragmaswitch.com

  • Error: unknown entity type 'Archive' when building external library

    Hi,
    This is what I get when trying to build a external library in SP14. If I look at the Libraries.pp files there are entries like this:
    <entity>
         <name>CLASSES12.JAR</name>
         <package></package>
         <caption>CLASSES12.JAR</caption>
         <description></description>
         <entity-type>Archive</entity-type>
         <entity-sub-type>Java Library</entity-sub-type>
    </entity>
    CLASSES12.JAR is a jar file I've added to the libraries folder and then added to the Public part (used <a href="/people/valery.silaev/blog/2005/09/14/a-bit-of-impractical-scripting-for-web-dynpro blog</a> as an example)
    Build log:
    Development Component Build (2006-02-23 10:27:16)
    Component name: lib
    Component vendor: XXXXXXXXX.com
    SC compartment: MyComponents
    Configuration: LocalDevelopment
    Location: local
    Source code location: jarpak@XXXXXXXXX
    DC root folder: C:\Documents and Settings\jarpak\.dtc\LocalDevelopment\DCs\XXXXXXXXX\lib\_comp\
    DC type: External Library
    Host: XXXXXXXXX
    DC Model check:
    [dcmake] All used DCs are available locally
    [dcmake] validating dependency to build plugin "sap.com/tc/bi/bp/externalarchive"
    [dcmake] DC model check OK
    Start build plugin:
    [dcmake] using build plugin: sap.com/tc/bi/bp/externalarchive
    [dcmake] starting build plugin from : C:\Program Files\SAP\JDT\eclipse\plugins\com.sap.tc.ap\comp\SAP_BUILDT\DCs\sap.com\tc\bi\bp\externalarchive\_comp\gen\default\public\lib\
    Build Plugins Version 6.40.0.111 (ExternalArchivePlugin, 630_VAL_REL ) from 2005-09-09 23:37:14 CEST
    Building development component 'lib', vendor 'XXXXXXXXX', type 'External Library'
    software component 'MyComponents', vendor 'sap.com'.
    location 'local'.
    source code location 'jarpak@XXXXXXXXX'.
    General options:
    convert *.xlf to *.properties: yes
    include sources for debugging: yes
    Reading BuildInfrastructure extension from DC tc/bi/util (vendor sap.com)
    Added technology 'sap.com/tc/bi/core'
    Error: unknown entity type 'Archive'.
    Cleaning up.
    Regards,
    Jari

    Hi,
    Solved it on my own with
    Re: Activation Error: "unknown entity type 'Archive'" thread.
    Jari

  • Super type hides child entity's synonym in Logical diagram

    Hi,
    I think that I found a bug:
    I created two entities: entity A and entity B.
    Entity A is super type of entity B.
    I created a synonym for entity B.
    When I select entity A it hides the synonym of entity B.
    When I create entity C and create a 1:N relation between synonym of entity B and entity C
    and move entity A (it contains entity B and its synonym) the relation's line is not moved, it is hanging in the air.
    My version: 3.0.0.665
    Java: 1.6.0_22
    Screenshot fragments:
    [url http://s4.postimage.org/262qg0w10/Screen_shot_2011_03_07_at_08_44_06.png]before moving
    [url http://s4.postimage.org/cswtio7hs/Screen_shot_2011_03_07_at_08_44_27.png]after moving
    Best regards.

    Hi,
    I logged bug for that.
    Philip

  • Deploying BMP Entity Bean with primary key calss

    Hi,
    I am using EJB 2.0 with and websphere studio 5.0 and database is sql server 2000.
    My BMP Entity bean has a primary key class.From my client I am invoking the Entity Bean by calling it's findbyprimarykey method.
    The home interface of my findbyprimarykey method returns a class of type Remote.But in the Entity Bean class,the return type is the primarykey class type.
    My problem is invoking this findbyprimarykey from the client to get the remote interface so that the other business methods of the entity bean can be called.
    The control goes into the ejbFindbyPrimaryKey but when it is returing from the Entity Bean class,it gives a remote exception (as the return type in Entity Bean class and Home interface are different for the findbyprimarykey method).
    I think that somewhere in the deployment decriptor in my websphere,i have to specify the primarykey class type,which i am missing out and hence getting the error.
    Please help me out with your advice and solution.
    Thanks
    Rahul Priyadarshi

    Hi,
    Sorry to disturb you again.
    Even my code is also almost the same....i am pasting the code below...Please go through it and let me know if I have made any mistake..
    EditVendorEntityBean.....(Bean Class)
    package code.beans.EditVendor;
    import code.beans.dataAccess.*;
    import javax.ejb.CreateException;
    import javax.ejb.RemoveException;
    import javax.ejb.EntityBean;
    import javax.ejb.EntityContext;
    import javax.ejb.EJBException;
    import javax.ejb.FinderException;
    import javax.ejb.ObjectNotFoundException;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import java.sql.*;
    import javax.sql.*;
    import java.util.*;
    * Bean implementation class for Enterprise Bean: EditVendorEntity
    public class EditVendorEntityBean implements javax.ejb.EntityBean {
         private static Hashtable dataSources = new Hashtable();
         private String username;
    private int Vendor_ID;
    private int Category_Id;
    private String Category_Name;
    private String Vendor_Name;
    private String Vendor_Address1;
    private String Vendor_Address2;
    private String Contact_Name;
    private String Home_Phone;
    private String Work_Phone;
    private String email;
    private String faxno;
    private String userloginname;
    private boolean dirtyFlag = false;
    private EntityContext context;
    private static final String DS_NAME = "jdbc/spiPOPS";
    Connection con = null;
    Statement stmt = null;
    PreparedStatement st = null;
    ResultSet res = null;
         //***********************Business Methods*********************
    // Begin of Busines Methods
    public void setData (String[] catname, String vendorname,String vendadd1,String vendadd2,String vendcontact,String venoff,String venres,String mailid,String venfax) {
              System.out.println("in setData where Vendor Id= "+ Vendor_ID);
                   boolean status=false;
                   boolean existing=false;
                   ArrayList cat=new ArrayList();
                   try
                        cat=getcategorylist(this.Vendor_ID);
                   catch(SQLException e)
                        System.out.println("Could not get category list");
                   System.out.println("Size of cat array -->" + cat.size() + " and string array size -->" + catname.length);
                   if(catname.length>0)
                        //Removing unwanted vendor categories for a particular vendor id
                        for(int i=0;i<cat.size();i++)
                                  existing=false;
                                  String tempdata=(String)cat.get(i);
                                  for(int j=0;j<catname.length;j++)
                                       if(tempdata.equals(catname[j]))
                                            existing=true;
                                  if(!existing)
                                       try
                                            delvencat(this.Vendor_ID,tempdata.trim());
                                       catch(SQLException e)
                                            System.out.println("Could not delete record in POPS_VENDOR_CATEGORY for -->" + tempdata);
                   //Adding new vendor categories for a particular vendor
                        try
                                  for(int i=0;i<catname.length;i++)
                                       status=false;
                                       String strcat=catname;
                                       status=checkcat(this.Vendor_ID,strcat.trim());
                                       if(!status)
                                            insertvencat(this.Vendor_ID,strcat.trim());
                        catch(SQLException e)
                                  System.out.println("Could not insert or select from POPS_VENDOR_CATEGORY table");
                   this.Vendor_Name          =vendorname;
              this.Vendor_Address1     =vendadd1;
              this.Vendor_Address2     =vendadd2;
              this.Contact_Name          =vendcontact;
              this.Work_Phone               =venoff;
              this.Home_Phone               =venres;
              this.email                    =mailid;
              this.faxno                    =venfax;
                   dirtyFlag = true;
                   System.out.println("Leaving set data method");
    public Vector getData() {
         Vector vctRec=new Vector();
         ArrayList arrdatas = new ArrayList();
         arrdatas.add(""+this.Vendor_ID);
         arrdatas.add(this.Vendor_Name);
         arrdatas.add(this.Vendor_Address1);
         arrdatas.add(this.Vendor_Address2);
         arrdatas.add(this.Contact_Name);
         arrdatas.add(this.Work_Phone);
         arrdatas.add(this.Home_Phone);
         arrdatas.add(this.email);
         arrdatas.add(this.faxno);
         vctRec.addElement(arrdatas);
         ArrayList cat=new ArrayList();
              try
              System.out.println("Calling getcategorylist from getdata with vendorid-->" + this.Vendor_ID);
              cat          = getcategorylist(this.Vendor_ID);
         catch(SQLException e)
                   System.out.println("Could not get datas for category list");
         vctRec.addElement(cat);
         ArrayList allcats=new ArrayList();
         try
                        allcats          = getallcategorylist();
              catch(SQLException e)
                        System.out.println("Could not get datas for category list");
         vctRec.addElement(allcats);
              dirtyFlag = false;
         System.out.println("Before return statement in getdata with vector size -->" + vctRec.size());
              return vctRec;
    // End of Business Methods
    //**************************Entity Bean Methods*******************************
         * ejbActivate
         public void ejbActivate() {
              Vendor_ID = Integer.parseInt((String)context.getPrimaryKey());
         System.out.println("Inside ejbActivate Vendor_ID-->"+ Vendor_ID);
         * ejbLoad
         public void ejbLoad() {
              System.out.println("Inside ejbLoad ********" );
    try {
    loadRow();
    }catch (Exception ex) {
              System.out.println("Failed in loadRow()");
    throw new EJBException("ejbLoad: " +
    ex.getMessage());
         * ejbPassivate
         public void ejbPassivate() {
         System.out.println("Inside ejbPassivate " );
    Vendor_ID = 0;
         * ejbRemove
         public void ejbRemove() throws javax.ejb.RemoveException {
              //Empty Method
         * ejbStore
         public void ejbStore() {
    System.out.println("Inside ejbStore " );
    try {
    storeRow();
    }catch (Exception ex) {
              System.out.println("Exception thrown in storeRow" + ex.getMessage());
    throw new EJBException("ejbLoad: " +
    ex.getMessage());
         * getEntityContext
         public javax.ejb.EntityContext getEntityContext() {
              return context;
         * setEntityContext
         public void setEntityContext(javax.ejb.EntityContext ctx) {
              System.out.println("Inside setEntityContext " );
    try{
         con = getConnection(DS_NAME);
         System.out.println("DB Connection Created!!");
    catch(Exception e){
    this.context = ctx;
         * unsetEntityContext
         public void unsetEntityContext() {
    System.out.println("Inside unsetEntityContext " );
    closeDbConnection(con, res, st);
    this.context = null;
         * ejbCreate
         //code.beans.EditVendor.EditVendorEntityKey
         public code.beans.EditVendor.EditVendorEntityKey ejbCreate(String vendorid)
              throws javax.ejb.CreateException {          
              return new EditVendorEntityKey(vendorid);
              //return null;
         * ejbPostCreate
         public void ejbPostCreate(String vendorid) throws javax.ejb.CreateException {
              //Empty
         * ejbFindByPrimaryKey
         //code.beans.EditVendor.EditVendorEntityKey
         public code.beans.EditVendor.EditVendorEntityKey ejbFindByPrimaryKey(
              code.beans.EditVendor.EditVendorEntityKey primaryKey)
              throws javax.ejb.FinderException {
    try {
    if(selectByPrimaryKey(Integer.parseInt(primaryKey.getVendorId()))) {
              System.out.println("Leaving the findbyprimarykey method from the entity bean");
         return primaryKey;
         //return null;
    }else {
         throw new ObjectNotFoundException
         ("Row for id " + primaryKey + " not found.");
    }catch (Exception ex) {
    throw new EJBException("EXCEPTION IN ejbFindByPrimaryKey :- " + ex.getMessage());
         /*********************** Database Utility Routines *************************/
    private boolean selectByPrimaryKey(int priKey)
    throws SQLException {
         System.out.println("inside selectByPrimaryKey for primary key " + priKey);
    String queryStr ="SELECT VENDOR_ID FROM POPS_VENDOR WHERE VENDOR_ID = " + priKey;
    System.out.println("in selectByPrimaryKey where queryString is: "+ queryStr);
              stmt = con.createStatement();
    ResultSet result = stmt.executeQuery(queryStr);
    if(!result.next()) {
    stmt.close();
         System.out.println("Did not find "+priKey);
    return false;
    else { //Found the primaryKey
    Vendor_ID = result.getInt("VENDOR_ID");
    stmt.close();
    return true;
    private void loadRow() throws SQLException {
              System.out.println("inside loadRow ...");
              stmt = con.createStatement();
              String queryStr = "SELECT VENDOR_NAME,VENDOR_ADDRESS1,VENDOR_ADDRESS2,CONTACT_NAME,HOME_PHONE,WORK_PHONE,EMAIL_ID,FAX_NO " +
                                  "FROM POPS_VENDOR WHERE VENDOR_ID=" + Vendor_ID;
              System.out.println("Inside loadRow()***********"+queryStr);
              ResultSet result = stmt.executeQuery(queryStr);
              ArrayList catadatas=new ArrayList();
         if(!result.next())
         throw new SQLException("No record for primary key" + Vendor_ID);
              this.Vendor_ID               =Vendor_ID;
                        this.Vendor_Name          =result.getString("VENDOR_NAME");
                        this.Vendor_Address1     =result.getString("VENDOR_ADDRESS1");
                        this.Vendor_Address2     =result.getString("VENDOR_ADDRESS2");
                        this.Contact_Name          =result.getString("CONTACT_NAME");
                        this.Home_Phone               =result.getString("HOME_PHONE");
                        this.Work_Phone               =result.getString("WORK_PHONE");
                        this.email                    =result.getString("EMAIL_ID");
                        this.faxno                    =result.getString("FAX_NO");
                             System.out.println("Leaving loadrow method with loaded datas for vendor -->" + Vendor_ID);
                             stmt.close();
    private ArrayList getcategorylist(int vendor) throws SQLException{
              String queryStr ="SELECT DISTINCT(VENDOR_CAT) FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID=" + vendor;
              System.out.println("Query for the cat list --> " + queryStr);
              stmt = con.createStatement();
              ResultSet result = stmt.executeQuery(queryStr);
              ArrayList catdatas=new ArrayList();
    try{
                   while(result.next())
                        catdatas.add(result.getString("VENDOR_CAT"));
              catch (SQLException e){
                   stmt.close();
                   System.out.println("Could not retrieve datas for Category list");
              stmt.close();
              System.out.println("size off array for cat -->" + catdatas.size() + " and datas ->" + catdatas);
              return catdatas;
         private ArrayList getallcategorylist() throws SQLException{
                   //String queryStr ="SELECT DISTINCT(VENDOR_CAT) FROM POPS_VENDOR_CATEGORY";
                   StringBuffer strquery=new StringBuffer(20);
                   strquery.append("SELECT DISTINCT(CATEGORY_NAME) FROM POPS_CATEGORY");
                   stmt = con.createStatement();
                   //ResultSet result = stmt.executeQuery(queryStr);
                   ResultSet result = stmt.executeQuery(strquery.toString());
                   ArrayList catdatas=new ArrayList();
                   try{
                        while(result.next())
                                  //catdatas.add(result.getString("VENDOR_CAT"));
                                  catdatas.add(result.getString("CATEGORY_NAME"));
                   catch (SQLException e){
                             stmt.close();
                             System.out.println("Could not retrieve datas for All Category list");
                   stmt.close();
                   return catdatas;
         private void delvencat(int vendor,String vencat) throws SQLException {
              int update=-1;
              stmt = con.createStatement();
              String queryStr ="DELETE FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID = " + vendor + " AND VENDOR_CAT = '" + vencat.toUpperCase() + "'";
              System.out.println("Delete query --> " + queryStr);
              update= stmt.executeUpdate(queryStr);
              if(update!=1)
                   System.out.println("Did not find data to delete");
              stmt.close();
         private void insertvencat(int vendor,String vencat) throws SQLException {
              int update=-1;
              String queryStr ="INSERT INTO POPS_VENDOR_CATEGORY(VENDOR_ID,VENDOR_CAT)" +
                                  " VALUES(" + vendor +",'" + vencat + "')";
              System.out.println("Insert query --> " + queryStr);
              stmt = con.createStatement();
              update=stmt.executeUpdate(queryStr);
              if(update!=1)
                   System.out.println("Could not insert records in the database");
              stmt.close();
         private boolean checkcat(int vendor,String catven) throws SQLException {
              boolean datastatus=false;
              String queryStr ="SELECT VENDOR_ID FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID = " + vendor + " AND VENDOR_CAT = '" + catven.toUpperCase() + "'";
              stmt = con.createStatement();
              ResultSet result = stmt.executeQuery(queryStr);
              datastatus=result.next();
              stmt.close();
              return datastatus;
    private void storeRow() throws SQLException {
                   System.out.println("Inside ejb store");
         if (!dirtyFlag) {
         System.out.println("Skipping the UPDATE because object is not dirty");
         return;
         CallableStatement cs=null;
    try{
                        cs = con.prepareCall("EXEC POPS_VENDOR_UPDATE " + this.Vendor_ID + ",'" + this.Vendor_Name + "','" + this.Vendor_Address1 + "','" + this.Vendor_Address2 + "','" + this.Contact_Name + "','" + this.Work_Phone + "','" + this.Home_Phone + "','" + this.email + "','" + this.faxno +"'");
                        System.out.println("\n\n SQL Statement : \n " + "EXEC POPS_VENDOR_UPDATE " + this.Vendor_ID + ",'" + this.Vendor_Name + "','" + this.Vendor_Address1 + "','" + this.Vendor_Address2 + "','" + this.Contact_Name + "','" + this.Work_Phone + "','" + this.Home_Phone + "','" + this.email + "','" + this.faxno +"'");
                        cs.executeUpdate();
              catch (SQLException e){
                        cs.close();
                        System.out.     println("\n\n Error in calling stored procedure POPS_INSERT_NEW_REQUEST \n\n"+ e.getMessage() + "\n\n");
              cs.close();
              dirtyFlag = false;
         private Connection getConnection(String dbName) throws SQLException
              String configuredDataSourceName = null;
              if (dbName == null) {
                   System.out.println("Attemp to get connection failed. The requested database name is null");
              DataSource dbSource = getDataSource(dbName);
              return dbSource.getConnection();
         private DataSource getDataSource(String dbName)
              // looking from cache;
              DataSource dbSource = (DataSource) dataSources.get(dbName);
              if (dbSource == null) { //we need to find it from JNDI
                   try {
                        Context ic = new InitialContext();
                        dbSource = (DataSource) ic.lookup(dbName);
                        dataSources.put(dbName, dbSource);
                   }catch (NamingException e){
              return dbSource;
         * User calls this function to safely close an connection
         * @param connt The connection a datasource
         * @param rs The resulSet inside this connection
         * @param statement The statement associate with this connection
         private void closeDbConnection(Connection cont,ResultSet rs,Statement statement)
              if (rs != null)
              try {
                        rs.close();
                   } catch (SQLException ignored) {
                        ignored.printStackTrace();
              if (statement != null)
                   try {
                        statement.close();
                   } catch (SQLException ignored) {
                        ignored.printStackTrace();
              if (cont != null)
                   try {
                        cont.close();
                   } catch (SQLException ignored) {
                        ignored.printStackTrace();
         } //closeDbConnection
    EditVendorEntity (Remote Interface)
    package code.beans.EditVendor;
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    import java.util.*;
    * Remote interface for Enterprise Bean: EditVendorEntity
    public interface EditVendorEntity extends javax.ejb.EJBObject {
         public void setData (String[] catname, String vendorname,String vendadd1,String vendadd2,String vendcontact,String venoff,String venres,String mailid,String venfax)
                   throws RemoteException;
    public Vector getData() throws RemoteException;
    EditVendorEntityHome (Home Interface)
    package code.beans.EditVendor;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.ejb.FinderException;
    import javax.ejb.DuplicateKeyException;
    import javax.ejb.EJBHome;
    import java.util.*;
    * Home interface for Enterprise Bean: EditVendorEntity
    public interface EditVendorEntityHome extends javax.ejb.EJBHome {
         * Creates an instance from a key for Entity Bean: EditVendorEntity
         public code.beans.EditVendor.EditVendorEntity create(String vendorid)
              throws javax.ejb.CreateException, java.rmi.RemoteException;
         * Finds an instance using a key for Entity Bean: EditVendorEntity
         public code.beans.EditVendor.EditVendorEntity findByPrimaryKey(
              code.beans.EditVendor.EditVendorEntityKey Vendor_ID)
              throws javax.ejb.FinderException, java.rmi.RemoteException;
    EditVendorEntityKey (Primary Key Class)
    package code.beans.EditVendor;
    * Key class for Entity Bean: EditVendorEntity
    public class EditVendorEntityKey implements java.io.Serializable {
         static final long serialVersionUID = 3206093459760846163L;
         public String primkey;
         * Creates an empty key for Entity Bean: EditVendorEntity
         public EditVendorEntityKey() {  }
         public EditVendorEntityKey(String primarykey) {     
              this.primkey=primarykey;
         public String getVendorId() {
    return primkey;
         * Returns true if both keys are equal.
         public boolean equals(java.lang.Object otherKey) {
              if (otherKey instanceof code.beans.EditVendor.EditVendorEntityKey) {
                   code.beans.EditVendor.EditVendorEntityKey o =
                        (code.beans.EditVendor.EditVendorEntityKey) otherKey;
                   return (primkey.equals(otherKey));
              return false;
         * Returns the hash code for the key.
         public int hashCode() {
              return (primkey.hashCode());
    Please go through and give me your comments and solution...
    Thanks in advance
    Rahul

  • Non-sequential IDs assigned using sequence="ID" on PrimaryKey

    Hello,
    I've seen some people asking something similar but I can't get this thing to work and it's driving me crazy. I'm using je-3.2.23 BTW.
    I have this simple class:
    * SYSADM.java
    * Created on 26 de junio de 2007, 09:29 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package haven;
    import com.sleepycat.persist.model.Entity;
    import com.sleepycat.persist.model.PrimaryKey;
    * @author Mario
    @Entity
    public class SYSADM extends Usuario{
    private boolean root;
    @PrimaryKey(sequence="ID")
    private long id;
    /** Creates a new instance of SYSADM */
    public SYSADM() {
    /** Creates a new instance of SYSADM from parameters */
    public SYSADM(boolean root,long id, String loginName, String password, String nombre, String apellido, String email) {
    super(loginName, password, nombre, apellido, email);
    setRoot(root);
    //setId(id);
    /** Creates a new instance of SYSADM from a VOSYADM */
    public SYSADM(VOSYSADM voSYSADM) {
    super(voSYSADM.getLoginName(),voSYSADM.getPassword(),
    voSYSADM.getNombre(),voSYSADM.getApellido(),voSYSADM.getEmail());
    setRoot(voSYSADM.isRoot());
    //setId(voSYSADM.getId());
    public VOSYSADM getVOSYSADM() {
    return new VOSYSADM(this.isRoot(),this.getId(),this.getLoginName(),this.getPassword(),
    this.getNombre(),this.getApellido(),this.getEmail());
    public boolean isRoot() {
    return root;
    public void setRoot(boolean root) {
    this.root = root;
    public long getId() {
    return id;
    public void setId(long id) {
    this.id = id;
    and when I add records to the database using DPL I get ids like 1,101,201... and so on.
    I've looked at all the examples and tested them myself and I get the same behavior from all the classes I test.
    Plus all the tutorials and materials say that this is plain simple... let me quote from PrimaryIndex:
    " Employee employee;
    employee = new Employee("Jane Smith");
    primaryIndex.putNoReturn(employee); // Inserts an entity
    assert employee.id == 1;
    employee = new Employee("Joan Smith");
    primaryIndex.putNoReturn(employee); // Inserts an entity
    assert employee.id == 2; "
    I don't get... may be I'm plain dumb... should've ask that first to myself... I'm getting desperate here people... really!
    Anyway... any help is much appreciated.
    Regards to all,
    Mario

    First of all many thanks for your feedback... it's
    really encouraging in times of desperation to find
    somebody out willing and actually helping you! You're welcome!
    This is good. I'm aware of how RDBMS are integrated
    in the AS. Basically you need the driver and the
    connection to the database. For DBD JE I have made a
    simple test and I can persist objects from a web
    application in the AS. I simply open the environment
    that points to a directory in the file system. I
    suppose that as long as that directory is accessible
    through the network it should be fine. Is this
    correct?That''s correct. However, I strongly recommend that the Environment directory be on a local disk. There are problems with using NFS, see:
    http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#1
    The question of scalability arises. As far as I read
    DBD C is the number one embeddable OpenSource
    Database out there. So I assume the same would apply
    for BDB JE some day (more even once it gets HA). How
    scalable is BDB JE? The limitation seems to be the
    available space in the machine where the filesystem
    is located? Does the filesystem have to the same
    where the AS is installed?It sounds like you're asking about data size scalability, not processor scalability. Yes, the limitation is the amount of file storage available, via a single directory, from the process that embeds JE. JE uses the standard java.io package for creating and accessing log files, so any hardware and file system that works under that API will work, as long as file locking is supported as mentioned in the FAQ above. JE creates numbered log files in sequence from 00000000.jdb to FFFFFFFF.jdb, and you can configure the size of the files. The default size is 10 MB.
    Ok I 'll look into it. Specialy into what a "Service"
    is. Off the top of my head I guess that by service
    you are referring to a stateless ejb implementing the
    Singleton pattern so you have only one instance
    running at all times, that embeds all database
    interactions, opens the environment at creation time,
    give data-accessors and thus handles all access to
    the database. Exactly.
    Should I open all indexes in the
    Singleton at creation time as well and simply get
    data-accessors to to perform read/write operations?Yes, that's what I recommend. See:
    http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#12
    Ok we willhave to wait then. One of the questions I
    received about BDB JE is why a JE when you have the C
    version with a Java API? I guess it's related to
    being written in Java (portability-wise), it runs in
    the same JVM and it's 100% Java codeYes, this is the primary reason. A pure Java library is easier to deploy, test and debug than a C-based library, especially if you target multiple platforms. And the product can be optimized for the Java platform.
    and that it
    incorporates the DPL much in the way JPA works to
    have a closer integration. Am I correct?The DPL is only available for the JE product today, but it may be available for the C product in the future, since it is implemented on top of the base Java API that is common to both products.
    Also, while the JE product has similar functionality to the C product, it uses a different internal architecture. JE uses a log structured storage system rather than a traditional page-based storage system; this is better for writing (disk head moves less) but worse for fetching records that are not in cache (disk head moves more). JE also uses record locking rather than page locking; this improves concurrent access but uses more memory for locks.
    See "Berkeley DB Java Edition Architecture" here:
    http://www.oracle.com/technology/products/berkeley-db/je/index.html
    Last but not least. Portability-wise we are using DAO
    to persist and in the DAOs we perisist the objects.
    My logic is that by decorating POJOs with BDB JE
    annotations i can use DAO to persist in DB JE, any
    other persistency type including text, dbf, RDBMs
    using an ORM (without JPA), or creating a separate
    set of classes decorated with JPA annotations (though
    I would stick with ANSI SQL if I could). Do you see
    this as correct? Would you reccomend using DAO at all
    with Berkeley?Yes, a DAO is a good idea when you need to target multiple storage mechanisms. And the DPL does not meet this need, because it can only be used for Berkeley DB JE.
    If you need an API that works very well for Berkeley DB (JE and C products), plus relational DBs, then I strongly recommend Carbonado, an open-source framework from Amazon:
    http://carbonado.sourceforge.net/
    Mark

  • Exception [EJB - 10008]: Cannot find bean of type [SalesBean] using finder

    I'm trying to call an entity bean froma session bean i get the error :-
    7/02/27 14:35:25 javax.ejb.ObjectNotFoundException: Exception [EJB - 10008]: Cannot find bean of type [SalesBean] using finde
    [findByCustID].
    7/02/27 14:35:25       at oracle.toplink.internal.ejb.cmp.EJBExceptionFactory.objectNotFound(EJBExceptionFactory.java:325)
    7/02/27 14:35:25       at oracle.toplink.internal.ejb.cmp.finders.Finder.checkNullResult(Finder.java:224)
    My session bean looks like this :-
    public class HelloBean implements SessionBean
      public String helloWorld (String pzCustomerID) throws SQLException,RemoteException
         String lzRevenue=null;
         int liCustomerID=Integer.parseInt(pzCustomerID);
         try
              Context initial = new InitialContext();
              Object objref =   initial.lookup("SalesBean");
              SalesHome salesHome =(SalesHome) PortableRemoteObject.narrow(objref,SalesHome.class);
              Sales sales=salesHome.findByCustID(liCustomerID);
              lzRevenue=(String) sales.findByCustID(liCustomerID);
    My entity bean looks like this:-
    public class SalesBean implements EntityBean
      public String factPK;
      public int timeID;
      public int custID;
      public int locID;
      public int itemID;
      public int entityID;
      public String currency;
      public float qty;
      public float unitPrice;
      public float amount;
      public EntityContext context;
      private Connection con;
        private void makeConnection() {
            try {
                InitialContext ic = new InitialContext();
                javax.sql.DataSource ds = (javax.sql.DataSource) ic.lookup("jdbc/DSource");
                con = ds.getConnection();
            } catch (Exception ex) {
                throw new EJBException("Unable to connect to database. " +
                    ex.getMessage());
      public SalesBean()
      public String ejbFindByCustID(int custID) throws SQLException,RemoteException,FinderException
         makeConnection();
         PreparedStatement pstmt = con.prepareStatement("select sum(amount) from sales where cust_id= ? ");
         pstmt.setInt(1, custID);
         ResultSet rset = pstmt.executeQuery();
         if (!rset.next())
              throw new RemoteException("no records present" );
         return rset.getString(1);
      }My entity bean's home interface looks like this:-
    public interface SalesHome extends EJBHome
    public Sales create() throws RemoteException, CreateException;
    public Sales findByCustID(int custID) throws SQLException,RemoteException,FinderException;
    My entity bean's remote interface looks like this:-
    public interface Sales extends EJBObject
         public String findByCustID(int custID) throws SQLException,RemoteException,FinderException;
    my ejb-jar.xml looks like this:-
    <enterprise-beans>
    <session>
    <description>Hello Bean</description>
    <ejb-name>HelloBean</ejb-name>
    <home>myEjb.HelloHome</home>
    <remote>myEjb.HelloRemote</remote>
    <ejb-class>myEjb.HelloBean</ejb-class>
    <session-type>Stateful</session-type>
    <transaction-type>Container</transaction-type>
    </session>
         <entity>
              <ejb-name>SalesBean</ejb-name>
              <home>myEjb.SalesHome</home>
              <remote>myEjb.Sales</remote>
              <ejb-class>myEjb.SalesBean</ejb-class>
              <persistence-type>Container</persistence-type>
              <prim-key-class>java.lang.String</prim-key-class>
              <reentrant>False</reentrant>
              <cmp-field>
              <field-name>factPK</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>timeID</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>custID</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>locID</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>itemID</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>entityID</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>currency</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>qty</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>unitPrice</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>amount</field-name>
         </cmp-field>
              <primkey-field>factPK</primkey-field>
              <resource-ref>
              <res-ref-name>jdbc/DSource</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
         </resource-ref>
         </entity>
    </enterprise-beans>
    please help me out of this trouble.

    I'm trying to call an entity bean froma session bean i get the error :-
    7/02/27 14:35:25 javax.ejb.ObjectNotFoundException: Exception [EJB - 10008]: Cannot find bean of type [SalesBean] using finde
    [findByCustID].
    7/02/27 14:35:25       at oracle.toplink.internal.ejb.cmp.EJBExceptionFactory.objectNotFound(EJBExceptionFactory.java:325)
    7/02/27 14:35:25       at oracle.toplink.internal.ejb.cmp.finders.Finder.checkNullResult(Finder.java:224)
    My session bean looks like this :-
    public class HelloBean implements SessionBean
      public String helloWorld (String pzCustomerID) throws SQLException,RemoteException
         String lzRevenue=null;
         int liCustomerID=Integer.parseInt(pzCustomerID);
         try
              Context initial = new InitialContext();
              Object objref =   initial.lookup("SalesBean");
              SalesHome salesHome =(SalesHome) PortableRemoteObject.narrow(objref,SalesHome.class);
              Sales sales=salesHome.findByCustID(liCustomerID);
              lzRevenue=(String) sales.findByCustID(liCustomerID);
    My entity bean looks like this:-
    public class SalesBean implements EntityBean
      public String factPK;
      public int timeID;
      public int custID;
      public int locID;
      public int itemID;
      public int entityID;
      public String currency;
      public float qty;
      public float unitPrice;
      public float amount;
      public EntityContext context;
      private Connection con;
        private void makeConnection() {
            try {
                InitialContext ic = new InitialContext();
                javax.sql.DataSource ds = (javax.sql.DataSource) ic.lookup("jdbc/DSource");
                con = ds.getConnection();
            } catch (Exception ex) {
                throw new EJBException("Unable to connect to database. " +
                    ex.getMessage());
      public SalesBean()
      public String ejbFindByCustID(int custID) throws SQLException,RemoteException,FinderException
         makeConnection();
         PreparedStatement pstmt = con.prepareStatement("select sum(amount) from sales where cust_id= ? ");
         pstmt.setInt(1, custID);
         ResultSet rset = pstmt.executeQuery();
         if (!rset.next())
              throw new RemoteException("no records present" );
         return rset.getString(1);
      }My entity bean's home interface looks like this:-
    public interface SalesHome extends EJBHome
    public Sales create() throws RemoteException, CreateException;
    public Sales findByCustID(int custID) throws SQLException,RemoteException,FinderException;
    My entity bean's remote interface looks like this:-
    public interface Sales extends EJBObject
         public String findByCustID(int custID) throws SQLException,RemoteException,FinderException;
    my ejb-jar.xml looks like this:-
    <enterprise-beans>
    <session>
    <description>Hello Bean</description>
    <ejb-name>HelloBean</ejb-name>
    <home>myEjb.HelloHome</home>
    <remote>myEjb.HelloRemote</remote>
    <ejb-class>myEjb.HelloBean</ejb-class>
    <session-type>Stateful</session-type>
    <transaction-type>Container</transaction-type>
    </session>
         <entity>
              <ejb-name>SalesBean</ejb-name>
              <home>myEjb.SalesHome</home>
              <remote>myEjb.Sales</remote>
              <ejb-class>myEjb.SalesBean</ejb-class>
              <persistence-type>Container</persistence-type>
              <prim-key-class>java.lang.String</prim-key-class>
              <reentrant>False</reentrant>
              <cmp-field>
              <field-name>factPK</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>timeID</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>custID</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>locID</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>itemID</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>entityID</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>currency</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>qty</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>unitPrice</field-name>
         </cmp-field>
         <cmp-field>
              <field-name>amount</field-name>
         </cmp-field>
              <primkey-field>factPK</primkey-field>
              <resource-ref>
              <res-ref-name>jdbc/DSource</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
         </resource-ref>
         </entity>
    </enterprise-beans>
    please help me out of this trouble.

  • Logical Model - Entity Attribute?

    Hi ,
    Thanks in responding to my posting.
    I am using SQL DM 3.0.0.665. I need your thoughs on following.
    1) Do we able to select multiple entities for entity reporting? I find an option for all entities then it ask us to pick only one entity to report.
    2) Are we able to build a report for all entities in a subview?
    3) I see Formula (Default Value), Preferred Abbreviation and Synonyms for each attribute in Entity Details report. I am not able to find a place to fill those in attribute definitions. Where can we supply those details, so it could print in reports?
    Thanks in helping us out.

    I find the following for Attribute Properties in SQL DM Help
    =============
    Attribute Properties
    This dialog box displays the properties of an attribute, which is a component of an entity in the Logical Model.
    General
    Name: Name of the attribute.
    Synonym: Synonym for the attribute.
    Preferred Abbreviation: Name that will be used for any corresponding table column during forward-engineering if the Use Preferred Abbreviations option is enabled in the Engineering dialog box.
    Long Name: Long name in the format: entity-name.attribute-name.
    Allow Nulls: Controls whether null values are allowed for the attribute. If this option is enabled, a non-null value is mandatory.
    Datatype: Enables you to specify a domain, logical type, distinct type, collection type, or structured type as the data type of the attribute. You can click the ellipsis (...) button to specify further details for the selected type.
    Entity: Name of the entity with which the attribute is associated.
    Source Name: User-specified name of the source for this attribute.
    Source Type: Manual, System, Derived, or Aggregate.
    Formula Description: For a derived or aggregate source type, the formula for the attribute.
    Scope: For a structured type with Reference enabled, limits the scope by specifying the table in which the type is implemented.
    Type Substitution: For a structured type with Reference disabled, or for a structured type applied to an entity, controls whether a substitutional structured type is generated in the DDL.
    Default and Constraint
    Constraint Name: Name of the constraint.
    Default Value: Default value for the attribute.
    Use Domain Constraints: Controls whether the properties defined in Domains Administration for the associated domain are used. If this option is disabled, you can use the remaining fields to specify the database type for the constraint and the ranges or a list of values.
    Constraint: Enables you to specify a constraint for one or more types of databases.
    Ranges: Enables you to specify one or more value ranges for the attribute.
    Value List: Enables you to specify a list of valid values for the attribute.
    Permitted Subtypes
    For a structured data type, lists all subtypes for the attribute, and lets you specify whether each is permitted for the attribute.
    =============
    but most of the above are not showing up in attribute definition window. How do we see those?

  • How to persist an entity with (any) Serializable Java Object as a field?

    Hello,
    I've understood, that in addition to basic and primary types, an entity bean can have basically any serializable object as its field. I just can't get it working. All I want, is just to have an entity bean with, for example, a HashMap or Properties as one of the its fields. And afterwards, when I'd query the bean again from the persistent storage, it would have the HashMap or Properties fields set just as they were while persisting the bean. So the basic functionality.
    So far, the only way I've gotten this working, is by defining the field as byte[] and then by using ObjectInput/OutputStreams and ByteArrayInput/OutputStreams I can read/write my HashMap or Properties as a byte[] and persist the entity... Not very clever, is it :)
    I've tried to annotate the field with @Lob but it eventually ends up with casting problems when fetching the data from the persistent storage, because TopLink gets a blob, a byte array from the persistent storage and doesn't know how to convert it into HashMap or Properties like I want it to.
    This was close to mine, but still didn't get it working..
    http://forum.java.sun.com/thread.jspa?threadID=749447&messageID=4287919
    ps. Working with AS PE9, MySQL and PostgreSQL..
    Best regards,
    Samuli

    Hello,
    Sorry, I'm not sure what you mean. The ID used for the entity does not need to match the actual database constraints, so you can use any mapping in the entity as the ID as long as its value will be unique. If it is not unique, you will run into problems when EclipseLink thinks the entity already exists, performing an update instead of an insert.
    Can you describe the performance problems you are having, and what type of sequencing you are using? It is possible to improve performance using batch writing and sequence pre-allocation.
    See http://wiki.eclipse.org/Optimizing_the_EclipseLink_Application_(ELUG)#How_to_Use_Batch_Writing_for_Optimization
    and http://wiki.eclipse.org/Optimizing_the_EclipseLink_Application_(ELUG)#Table_11-11 for some of the options available.
    Best Regards,
    Chris

Maybe you are looking for