CMP and TO

Hi,
i'm trying to use the TO (Transfer Object) Pattern, and i used Firestorm to generate all the TOs and CMP Entity Beans
I'm trying to create a new Entity Bean, and the create method for this CMP receives the TO (like it says on the Pattern).
The problem is that some of the TOs variables are primitive data (int, long, etc), all generated by Firestorm.
And i have some foreign keys in the table, and when i pass a TO to the CMP create i can't send any value as null (because they are primitive type), and so i get this error Cannot insert the value NULL into column 'date_modified', table 'sfa.dbo.ACCOUNTS'; column does not allow nulls. INSERT fails.The TO has a method called setModifiedUserIdNull, but even i put this value as true, i still get the same error
Anyone has any idea about this ?
Thank you

PS: it is only in case of bidirectional relation

Similar Messages

  • Could I build 1:N relationship between CMP and BMP?

    Hi, as subject, Could I build 1:N relationship between CMP and BMP?
    Thanks a lot!
    a13519

    Container managed relationships only apply to CMP beans. You can look at the DTD in appendix B of the EJB spec or chapter 10 where they make this distinction.

  • CMP and Serializable fields

    Hello,
    I would like to declare a field in an CMP Entity Bean to hold Serializable objects.
    It seems to work fine for primitive types and arrays of them but I get an exception as soon as I try to set the field via the bean remote interface with an instance of a user created class implementing Serializable :
    com.evermind.server.rmi.OrionRemoteException: Method invocation failed (Invalid return command: 6)
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
              RMIConnection.java:1499
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
              RMIConnection.java:1452
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
              RemoteInvocationHandler.java:55
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
              RecoverableRemoteInvocationHandler.java:22
         void __Proxy1.setBehaviour(java.io.Serializable)
         void cern.laser.business.test.ConsoleConfigurationEntityEJBClient.main(java.lang.String[])
              ConsoleConfigurationEntityEJBClient.java:27
    The class looks like :
    public class MyClass implements java.io.Serializable
    private String s;
    public MyClass ()
    s = new String("ciao ciao");
    The corresponding database column is defined as BLOB.
    Thanks for your help,
    Francesco.

    Can any body tell me the relation between cmp and cmr
    fields in CMP beans
    Thanks in Advance
    SudhakarWe could say:
    If an Entity EJB is a record of a database table, a CMP is like a simple table column and a CMR represents a table column refering to a Foreign Key.
    Fil

  • Cmp and datasource

    Hi,
    I have a application with CMPs, and in my iAS there are 5 Data Sources.
    How to configure an application to access a Data Source ?
    Jordi Pinyol Essi Projects
    Ingeniero de Desarrollo
    [email protected] t +34 977 221 182
    http://www.essiprojects.com f +34 977 230 170

    Hello,I need to change at runtime the properties of
    the connection, because my database has several users,
    I am working with CMP EJB . How could I do it?
    Thanks in advanceYou may write your own data source wich you will pass required data (user name) to through some thread oriented storage...
    class Store {
    static Map cache = new HashMap();
    static void setUserName(String userName) {
        cache.put(new Integer(Thread.currentThread.hashCode()), userName);
    static String gerUserName() {
        return (String)cache.get(new Integer(Thread.currentThread.hashCode()));
    EJB:
    setEntityContext(EC ec) {
       Store.setUserName(ec.getCallerPrincipal().getName());
    YourDS:
    getConnection() {
       return ds.getConnection(Store.getUserName(), ...);
    ...

  • CMP and capture-schema problems

    I am trying to deploy a CMP on Sun App Server 8, and I'm having a few problems. I am quite new to both CMP and Sun App Server 8.
    I've created a simple table Room in mySQL DB, containing only id (varchar) and description (varchar). I'm running this command to capture the table schema
    capture-schema -username username -password pwd -dburl jdbc:mysql://localhost/test -driver com.mysql.jdbc.Driver -out test.dbschema
    Do I need to enter the -schemaname and -table parameters as well? I'm assuming that since the url is pointing directly to the test schema in mySQL and it only contains the room table, I don't need these 2 parameters.
    test.dbschema gets generated, but when I use the deployment tool and create the database mappings to the entity bean using this schema file, no mappings are created.
    Any help?

    Hello,
    I have similar problem and I'm really confused about it.
    Working with:
    Java System Application Server Platform Edition 8.1 2005Q1 UR1
    mysql DataSource and Container Managed Persistence
    mysql-connector-java-3.0.8-stable-bin.jar
    I have problem with deploy:
    Fatal Error from EJB Compiler -- JDO74025: JDOCodeGenerator: Caught an Exception validating CMP bean 'Sets' in application 'isvl' module 'isvl-EJBModule': JDO72335: If the table sets for the bean corresponding to the generated class isvl.model.set.SetBean470758938_JDOState is mapped as the primary table, it must have a primary key.Choose a different primary table or verify that the contents of the schema file are correct.
    Choose a different primary table or verify that the contents of the schema file are correct. at com.sun.ejb.codegen.CmpCompiler.compile(CmpCompiler.java:274) at com.sun.ejb.codegen.IASEJBC.doCompile(IASEJBC.java:615) at com.sun.ejb.codegen.IASEJBC.ejbc(IASEJBC.java:563) at com.sun.enterprise.deployment.backend.EJBCompiler.preDeployApp(EJBCompiler.java :340) at com.sun.enterprise.deployment.backend.EJBCompiler.compile(EJBCompiler.java:209) at com.sun.enterprise.deployment.backend.AppDeployer.runEJBC(AppDeployer.java:284) at com.sun.enterprise.deployment.backend.AppDeployer.deploy(AppDeployer.java:176) at com.sun.enterprise.deployment.backend.AppDeployer.doRequestFinish(AppDeployer.j ava:107) at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:146) at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPh ase.java:71) at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeplo ymentService.java:633) at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentSe rvice.java:188) at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentSe rvice.java:520) at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:143) at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:172)
    Have you seen this problem?
    Thanks.

  • CMP and BMP configure for deploying in weblogic

    how to run CMP and BMP in weblogic and configure in welogic
    tell me the steps to be followed for connection pooling and deployement and configure in weblogic builder....

    Disagree that CMP is always better than BMP. CMP is in reality merely an implementation of BMP that provides a declarative method of providing a persistence layer. You could easily use other declarative systems to provide the same service, but you are alway relying on BMP and when CMP fails to provide you need to return to the raw BMP.
    It a bit like the difference between high/low level languages. We don't normally write direct assembly (yes, I am aware that real programmers yada yada yada) but we do use it, and sometimes you actually have to write it for specialised applications - most notably for high performance.
    Both have their pluses and minuses, and you need to know when to use one over the other.

  • CMP and BMP in application

    I am new to EJB, please help me on this:
    Can i have mix of CMP and BMP in my application?
    Is it best enforce that all entity bean in either one but not both?

    You are impling that BMP is DB-dependent. The SQL generated by the >Container is nothing magical. It is no more DB independent than SQL >written by the developer. You don't have to be DB-specific to use BMP, >but you do have to be appserver-specific to use CMP.By Db independent I mean that the sql code for container call back methods is generated by Container. You dont have to do anything. If you are deploying bean for oracle or sql , container will take care for that. Refer to the specs There is brief para on advantages of CMP.
    For BMP you have to change the code according to the database. Container will not do anything for that.
    "2. Reduced development efforts."
    Yes, marginally, but the reduction in initial development time must >be weighed against:
    The tools (or lack thereof) provided to map the beans to the tablesWell even if you are working with BMP you have to be aware of that. There are various performance improvement setting which are app server specific. It doesnt matter if you are using BMP or CMP for that matter
    The time spent dealing with appserver vendors when things don't workOfcourse this happens with BMP also.
    The inherent limited flexibility of CMPAlmost 90 % of the scenarios can be delt with CMP. Yes if not you can use BMP.
    Also if time is such a factor, you should probably be generating your >beans (either CMP or BMP). This eliminates the development effort >difference between them. Of course that means developing BMP will be >faster since you don't have to muck about with the appserver, mapping >beans, marking methods as read-only, etc.Ha... I cannot take it. In general I can say It doesnt matter if you are using BMP or CMP , you have to be aware of different performance and other settings which are app server specific.
    Remember CMP is available for 2 reasons:
    1) So you can minimize development effort on simple Object-to-RDB >mappingsThey now support various relationships like 1-1,1-many, many-many
    2) So that the big vendors (IBM, BEA, etc.) who were involved in >drafting the spec can provide "features" not in the specification, >encouraging vendor lock-in. Any Specification is not complet or exaustive. Vendors need to fill the gap.
    --Ashwani

  • Can TopLink CMP and POJO persistence be mixed (for incremental migration)?

    Is it possible to mix TopLink CMP and POJO persistence in one application server container? Does anyone already have experiences with such a setting?
    Background: We currently maintain an application that uses Toplink as CMP 1.1 provider for its entity beans. As this architecture is quite out-dated, we'd like to move from CMP 1.1 to POJO based persistence with TopLink (native, no JPA) and Spring inside the appserver.
    Is only a "big-bang" migration feasible? Or is there a way to use CMP and POJO persistence with TL side-by-side in one container? That would extremely handy allowing us to migrate each entity bean at a time.
    I would very much appreciate your input/opinion!
    Sebastian
    Application server is Bea Weblogic 8.1SP6
    Toplink version is 9.0.4.9
    Java version is 1.4.2

    Thank you a lot for your answer!
    I understand that with SessionAccessor from the oracle.toplink.ejb.cmp package, we can get access to the current CMP session.
    We'd like to use the TopLinkDaoSupport class from Spring's TL integration and for this, Spring wants a session factory injected.
    Is there a way to get something like a TL session factory for use with Spring in a CMP environment?
    Thanks again for your time!
    Sebastian

  • CMP and Transaction Attribute

    Hi All!
    I try to play with cmp entity beans. All I try to do is find instance and call one from the methods.
    When I use transaction attribute another than "Required", I get exception 25222. Application module creation exception.
    If I change attribute to "Required New" then I get error while bean try to UPDATE record.
    I can't understand why this update appear on findByPrimaryKey!
    Can any body give some information on JBO behavior?
    Mike
    null

    I do one more test and found
    UPDATE exception raised when I have foreign key in table. If I use only plain fild evething is ok. If add to entity foreign key field container raise exception when it try to update record.

  • App Server7 CMP and Invalid SQL

    I've recently started using App Server7 with Sybase and have run into (I think) a CMP generated SQL error. I attempting to execute a web app incorporating Related CMP Entity EJBs mapped to a pre-existing Sybase db.
    The app log reports the following error[s] and info:
    NestedException: com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near '='.
    SQL statement<select t0."pubname", t0."requestdate", t0."status", t0."prsid" from "rs_publications" t0 where t0."pdbid" = t0."pubname" = ?> with input values: com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.InputValue:PGLxAxysMainThe above WHERE clause is incorrect, t0."pdbid" (java.lang.Integer) is not equal to t0."pubname" (java.lang.String). But I've been unable to determine why Container is choosing to construct the statement in this way.
    Wtih the exception of this one troublesome EJB, the web app is successfully executing dozens of other Related EJBs without error.
    Any suggestions appreciated...

    Could you please post EJBQL for your finder.

  • Have trouble with CMP and relationships

    Hello and Thank you for your time.
    I'm having a bit of trouble using entity beans and CMP, I'm probably doing some thing wrong. The main problem I am having is with a many to many relationship. Let's say I have the following code:
    ClassA.java
    @Entity
    public class ClassA implements Serializable {
    <other variables>
    private Collection<Class1> class1Collection;
    <other methods>
    @ManyToMany(cascade=CascadeType.ALL, mappedBy = "classACollection")
    public Collection<Class1> getClass1Collection() {
    return class1Collection;
    public void setClass1Collection(Collection<Class1> class1Collection) {
    this.class1Collection = class1Collection;
    Class1.java
    @Entity
    public class Class1 implements Serializable {
    <other variables>
    private Collection<ClassA> classACollection;
    <other methods>
    @ManyToMany
    public Collection<ClassA> getClassACollection() {
    return class1Collection;
    public void setClassACollection(Collection<ClassA> classACollection) {
    this.class1Collection = class1Collection;
    In the 'other variables' each table has a @Id field and setters and getters for the Id.
    This code half works. If I set the collection in ClassA with a Collection of Class1 objects this is populated in to the database and the getClass1Collection method for this also works. If I then try to use the getClassACollection method from a Class1 object the entity manager throws a relationship not complete exception (or some thing to that effect). it is also the case that if I create a list of ClassA objects and place it in to the Class1 objects variable, this does not populate in to the database.
    Some thing similar also happens with OneToMany and ManyToOne relationship (only one side of the relationship seems to be part of the relationship)
    What am I doing wrong?
    Edited by: tehBoris on Mar 26, 2010 1:18 PM

    Yes, that's as it should be, but I think the problem is the default for adding the auto page numbers. The default on the top of the dialog box that appears when you choose Auto Page Numbers from the menu says:
    Show in Document.
    That seems to be the default.  Page numbers in sections won't work with that default. To get it to work, you have to select:
    Show in Current Section.
    I think I'm right on this, but I'm not sure. I'll have to practice some more. Perhaps this is a default that should be changed in the next version, but I don't know.
    Tom

  • WebLogic CMP and Oracle LONG columns

    I noticed that the Oracle LONG is not supported in
    http://edocs.bea.com/wls/docs61/ejb/cmp.html#1059575
    but doesn't seem to cause an error when I use it in the descriptors or
    column types.
    Am I going to be bopped on the head down the road with hidden issues? I'm
    trying to store arbitrarily (well, reasonably so) long strings? Should I use
    CLOBs instead? LONG are easier to work with other database tools which is
    why I'd prefer them but...
    thanks,
    greg

    The link you've mentioned doesn't say that Oracle long is not supported. In
    fact it is supported and the corresponding java data-type for WLS is
    Longvarchar.
    For more on this you can refer to
    http://e-docs.bea.com/wls/docs61//oracle/advanced.html#1158561 under "Data
    Types". Here you'll find elaborate discussion on Java supported data-types
    for Oracle.
    Regards,
    Santanu
    "Gregory Gerard" <[email protected]> wrote in message
    news:3c1f0784$[email protected]..
    I noticed that the Oracle LONG is not supported in
    http://edocs.bea.com/wls/docs61/ejb/cmp.html#1059575
    but doesn't seem to cause an error when I use it in the descriptors or
    column types.
    Am I going to be bopped on the head down the road with hidden issues? I'm
    trying to store arbitrarily (well, reasonably so) long strings? Should Iuse
    CLOBs instead? LONG are easier to work with other database tools which is
    why I'd prefer them but...
    thanks,
    greg

  • Unable to deploy ejb jar consisting CMP and Stateful in single ejb-jar.xml

    Hi
    I was able to deploy entity bean and stateless bean saperately but when i am trying to deploy a jar consisting of CMP entity and Stateless within single ejb-jar.xml it shows following errors.
    Auto-deploying ejb_SDCurrency.jar (No previous deployment found)... ISDCMCurrencyHome_EntityHomeWrapper4.java:830: 'finally'
    wi
    finally
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:835: 'try' without 'catch' or 'finally'.
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:838: 'catch' without 'try'.
    catch(java.sql.SQLException e)
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:889: '}' expected.
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:893: 'try' without 'catch' or 'finally'.
    public com.satyam.icalm.staticdata.currency.ISDCMCurrency findByCode(int argument0, java.lang.String argument1) throws
    javax.ej
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:893: Statement expected.
    public com.satyam.icalm.staticdata.currency.ISDCMCurrency findByCode(int argument0, java.lang.String argument1) throws
    javax.ej
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:961: 'finally' without 'try'.
    finally
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:966: 'try' without 'catch' or 'finally'.
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:968: 'catch' without 'try'.
    catch(java.sql.SQLException e)
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1017: '}' expected.
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1021: 'try' without 'catch' or 'finally'.
    public com.satyam.icalm.staticdata.currency.ISDCMCurrency findAllByCode(int argument0, java.lang.String argument1) throws
    javax
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1021: Statement expected.
    public com.satyam.icalm.staticdata.currency.ISDCMCurrency findAllByCode(int argument0, java.lang.String argument1) throws
    javax
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1371: 'finally' without 'try'.
    finally
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1376: 'try' without 'catch' or 'finally'.
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1378: 'catch' without 'try'.
    catch(java.sql.SQLException e)
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1427: '}' expected.
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1431: 'try' without 'catch' or 'finally'.
    public java.util.Enumeration findAuthorizedRecords(int argument0) throws javax.ejb.FinderException, java.rmi.RemoteException
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1431: Statement expected.
    public java.util.Enumeration findAuthorizedRecords(int argument0) throws javax.ejb.FinderException, java.rmi.RemoteException
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1496: 'finally' without 'try'.
    finally
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1501: 'try' without 'catch' or 'finally'.
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1504: 'catch' without 'try'.
    catch(java.sql.SQLException e)
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1555: '}' expected.
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1559: 'try' without 'catch' or 'finally'.
    public java.util.Enumeration findAllRecords(int argument0) throws javax.ejb.FinderException, java.rmi.RemoteException
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1559: Statement expected.
    public java.util.Enumeration findAllRecords(int argument0) throws javax.ejb.FinderException, java.rmi.RemoteException
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1624: 'finally' without 'try'.
    finally
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1629: 'try' without 'catch' or 'finally'.
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1632: 'catch' without 'try'.
    catch(java.sql.SQLException e)
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1683: '}' expected.
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1685: 'try' without 'catch' or 'finally'.
    public ISDCMCurrencyHome_EntityHomeWrapper4() throws java.rmi.RemoteException
    ^
    ISDCMCurrencyHome_EntityHomeWrapper4.java:1685: Statement expected.
    public ISDCMCurrencyHome_EntityHomeWrapper4() throws java.rmi.RemoteException
    ^
    30 errors
    Error compiling C:\oc4jext\j2ee\home\applications\calm6/ejb_SDCurrency.jar: Syntax error in source
    com.evermind.compiler.CompilationException: Syntax error in source
    at com.evermind.compiler.FileLinkedCompilation.run(FileLinkedCompilation.java:90)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.evermind.compiler.FileLinkedCompiler.compile(FileLinkedCompiler.java:19)
    at com.evermind.compiler.Javac.compile(Javac.java:37)
    at com.evermind.server.ejb.compilation.Compilation.compileClasses(Compilation.java:335)
    at com.evermind.server.ejb.compilation.Compilation.compile(Compilation.java:256)
    at com.evermind.server.administration.ServerApplicationInstallation.finish(ServerApplication
    Installation.java:439)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:80)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    Note:The same jar is deployed into Weblogic 5.1 and was working fine .....
    so please if any solutions .....
    regards,
    Sap

    Hi sapthapathi,
    From the information u have provided, i can only guess, that
    the problem is in ur code...Not in ejb-jar.xml....
    'coz there is no problem in combining stateless session bean and CMP entity bean information in a single ejb-jar.xml file...i myself have deployed bunch of CMPs with stateless session beans..
    So please check ur code once again....
    --Venky                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Cmp and required transaction

    Hi,
    I have a session bean starting a transaction ("requires new" in ejb descriptor),
    that bean is calling another session bean which has "required", this one is then
    setting some attributes in a CMP (setXxx), that also has required and then it
    throws an exception, the first session bean catches it and rolls back. But when
    I check in the db the value set by setXxx has been updated, shouldn't the whole
    transaction be rolled back?
    Thanks,
    A.

    Hi,
    I have a session bean starting a transaction ("requires new" in ejb descriptor),
    that bean is calling another session bean which has "required", this one is then
    setting some attributes in a CMP (setXxx), that also has required and then it
    throws an exception, the first session bean catches it and rolls back. But when
    I check in the db the value set by setXxx has been updated, shouldn't the whole
    transaction be rolled back?
    Thanks,
    A.

  • Default Isolatioin level in CMP and BMP

    Hi All,
    If we don't set isolation in a descriptor (in case of CMP) then what is the default level ?
    and what is the default level in case of BMP?
    Is it a Database dependent?

    Hi,
    Didnt find this reference in any books/pdf?
    Did u find the same?
    Seetesh
    isolation-level defines a valid transaction isolation level to apply to specific EJB
    methods. The following are possible values for isolation-level:
    TransactionReadUncommitted:: The transaction can view uncommitted updates from other transactions.
    TransactionReadCommitted: The transaction can view only committed updates from other transactions.
    TransactionRepeatableRead: Once the transaction reads a subset of data, repeated reads of the same data return the same values, even if other transactions have subsequently modified the data.
    TransactionSerializable: Simultaneously executing this transaction multiple times has the same effect as executing the transaction multiple times in a serial fashion.
    For Oracle databases only:
    TransactionReadCommittedForUpdate
    TransactionReadCommittedForUpdateNoWait

Maybe you are looking for