Problem in JPA ManyToMany relationship.

Please look at
[http://forums.sun.com/thread.jspa?threadID=5358105&tstart=30|http://forums.sun.com/thread.jspa?threadID=5358105&tstart=30]
thanks.

You could make a class called (for example) DegreeToSpecialization that would link a Degree to a Specialization (also why do you have specialization and specification?) and save those instead of having them separate.
Also I suspect there's something other faulty with your design too, but I just had lunch so I can't wrap my brain around this just yet. burp

Similar Messages

  • Problem with ejb 3.0 entity beans with manyToMany relationship

    Hello everyone!
    I am using struts 1.2.9 and java ee 5 sdk update 2 for my enterprise application. Besides others i have these entity beans Targetgroup.java and City.java, (i would upload file but i do not know how:)
    with manytomany relationship with join table.
    when user updates Targetgroup, by clicking on web page with checkboxes and textfields, struts dispatch action calls following method stateless bean:
    public void update(String firmId, String targetgroupId, String newGender, String newMinYearsOld, String newMaxYearsOld, String[] newCities) {
    TargetgroupPK pkForUpdate = new TargetgroupPK(targetgroupId, firmId);
    Targetgroup targetgroupForUpdate = find(pkForUpdate);
    targetgroupForUpdate.setGender(newGender);
    targetgroupForUpdate.setMinyearold(Integer.parseIn t(newMinYearsOld));
    targetgroupForUpdate.setMaxyearold(Integer.parseIn t(newMaxYearsOld));
    //pronalazenje gradva za koje je vezana ciljna grupa
    Collection<City> newCitiesCollection = new ArrayList<City>();
    for(int i = 0; i < newCities.length; i++){
    String tmp_city_name = newCities;
    City city_obj = cityFacade.find(tmp_city_name);
    newCitiesCollection.add(city_obj);
    targetgroupForUpdate.setCityidCollection(newCities Collection);
    parameter newCities represents names of cities which user checked on his update page. When the page is showen to him some cities are allready check because they were connected with Targetgruoup when it was created (targetgroup).
    this code throws following exception:
    [#|2007-07-26T12:13:36.993+0200|SEVERE|sun-appserver-pe9.0|javax.enterprise.system.container.web|_Threa dID=16;_ThreadName=httpWorkerThread-8080-0;_RequestID=f79d9c50-86b0-4b6c-96ab-97956dfb39c1;|StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
    javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
    javax.transaction.RollbackException: Transaction marked for rollback.
    at
    .com.sun.enterprise.web.connector.grizzly.WorkerTh read.run(WorkerThread.java:75)
    javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
    at com.sun.ejb.containers.BaseContainer.completeNewTx (BaseContainer.java:3659)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx( BaseContainer.java:3431)
    at com.sun.ejb.containers.BaseContainer.postInvoke(Ba seContainer.java:1247)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:1 92)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dlerDelegate.invoke(EJBLocalObjectInvocationHandle rDelegate.java:71)
    at $Proxy149.update(Unknown Source)
    at audiotel.sms.actions.backoffice.TargetgroupDispatc hAction.updateOrDelete(TargetgroupDispatchAction.j ava:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.struts.actions.DispatchAction.dispatchM ethod(DispatchAction.java:270)
    at org.apache.struts.actions.DispatchAction.execute(D ispatchAction.java:187)
    at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:431)
    at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:236)
    at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
    at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:727)
    com.sun.enterprise.web.connector.grizzly.WorkerThr ead.run(WorkerThread.java:75)
    |#]
    exceprion is throwen ONLY when in parameter newCities are city names allready connected to Targetgroup. when NewCities contains names of
    City objects which are not connected to Targetgroup it works fine, but it's of no use for me, because user must be able to add or remove certian cities from relaionship with Targetgroup. I think it's because there are rows in join table that contain primary keys of city and targetgroup which are connected so perisistence manager cann't write them again.
    i thought it was going to figure it out by itself, and only update those rows.
    Does anyone know what is the problem and solution?
    Thanks! (forgive my spelling errors :)

    solved the problem!
    I moved code from sesion bean to struts action as follows:
    CityFacadeLocal cityFacade = lookupCityFacade();
    //prikupljanje novih podataka o ciljnoj grupi
    String newGender = ctf.getGender();
    String newMaxYears = ctf.getMaxyears();
    String newMinYears = ctf.getMinyears();
    String[] newSelectedCities = ctf.getSelectedCities();
    //niz imena gradova se prevodi u kolekcju objekata City
    Collection<City> newCitiesObjCollection = new Vector<City>();
    for(int i = 0; i < newSelectedCities.length; i++){
    String tmpCityName = newSelectedCities;
    City tmpCityObj = cityFacade.find(tmpCityName);
    newCitiesObjCollection.add(tmpCityObj);
    //setovanje novih podataka
    targetgroupForUD.setGender(newGender);
    targetgroupForUD.setMinyearold(Integer.parseInt(newMinYears));
    targetgroupForUD.setMaxyearold(Integer.parseInt(newMaxYears));
    targetgroupForUD.setCityidCollection(newCitiesObjCollection);
    //pozivanje update metdoe u session beany
    targetgroupFacade.edit(targetgroupForUD);
    //korisnik se vraca na stranu sa svim postojecim ciljnim grupama
    forward = mapping.findForward("backend.targetgroups");
    and now it works fine. I guess probelm was same transaction scope for Targetgroup and City entities. Now when they are separated it works.
    Thanks!

  • EJBQL query problem in JPA

    I am developing an Enterprise application that uses JPA and toplink as the persistence provider. It uses MYSQL 5.1.
    The query used in the Entity class is :
    @NamedQueries({@NamedQuery(name = "AirtravelsDynamic.findAllEconomyFlights", query = "select NEW com.inter.transfer.Response(rf.flightno,d.economyseats,rf.ecofare,rf.arrtime,rf.depttime) from AirtravelsDynamic d LEFT JOIN d.refId rf where rf.source=?1 and rf.destination=?2 and d.availdate between ?3 and ?4") })
    This application is giving the following exception:
    Exception Description: Error compiling the query [AirtravelsDynamic.findAllEconomyFlights: select NEW com.inter.transfer.Response(rf.flightno,d.economyseats,rf.ecofare,rf.arrtime,rf.depttime) from AirtravelsDynamic d LEFT JOIN d.refId rf where rf.source=?1 and rf.destination=?2 and d.availdate between ?3 and ?4], line 1, column 40: invalid navigation expression [rf.flightno], cannot navigate expression [rf] of type [int] inside a query.
    Local Exception Stack:
    Exception [TOPLINK-8029] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EJBQLException
    Exception Description: Error compiling the query [AirtravelsDynamic.findAllEconomyFlights: select NEW com.inter.transfer.Response(rf.flightno,d.economyseats,rf.ecofare,rf.arrtime,rf.depttime) from AirtravelsDynamic d LEFT JOIN d.refId rf where rf.source=?1 and rf.destination=?2 and d.availdate between ?3 and ?4], line 1, column 40: invalid navigation expression [rf.flightno], cannot navigate expression [rf] of type [int] inside a query.
    at oracle.toplink.essentials.exceptions.EJBQLException.invalidNavigation(EJBQLException.java:430)
    at oracle.toplink.essentials.internal.parsing.DotNode.checkNavigation(DotNode.java:141)
    at oracle.toplink.essentials.internal.parsing.DotNode.validate(DotNode.java:97)
    at oracle.toplink.essentials.internal.parsing.ConstructorNode.validate(ConstructorNode.java:97)
    at oracle.toplink.essentials.internal.parsing.SelectNode.validate(SelectNode.java:329)
    at oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java:229)
    at oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java:211)
    at oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java:201)
    at oracle.toplink.essentials.internal.parsing.EJBQLParseTree.populateReadQueryInternal(EJBQLParseTree.java:134)
    at oracle.toplink.essentials.internal.parsing.EJBQLParseTree.populateQuery(EJBQLParseTree.java:108)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:219)
    at oracle.toplink.essentials.queryframework.EJBQLPlaceHolderQuery.processEjbQLQuery(EJBQLPlaceHolderQuery.java:111)
    at oracle.toplink.essentials.internal.sessions.AbstractSession.processEJBQLQueries(AbstractSession.java:2059)
    at oracle.toplink.essentials.internal.sessions.AbstractSession.processEJBQLQueries(AbstractSession.java:2046)
    at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:724)
    at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:604)
    at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:280)
    at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:229)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:93)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:126)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:120)
    at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:91)
    Any help is appreciated.
    Thanks in advance.

    What are you trying to do exactly? The way you've used LEFT JOIN is not correct if d.refId is an integer. LEFT JOIN is used to retrieve a set of entities where that set may not exist. It doesn't look like refId is a set of anything, just an integer.
    It looks like maybe you intended to have a foreign key relationship between AirtravelsDynamic and some other entity. In that case you probably want to model your AirtravelsDynamic entity as having a many-to-one relationship with the entity (let's call it ref.)
    The relationship would look something like:
    @Entity
    public class AirtravelsDynamic
       @ManyToOne
       @JoinColumn(name="refId")
       private Ref ref;
    }Then your query would read:
    SELECT new com.inter.transfer.Response(d.ref.flightno, d.economyseats,
                                           d.ref.ecofare, d.ref.arrtime,
                                           d.ref.depttime)
      FROM AirtravelsDynamic d
    WHERE d.ref.source = :refSource
       AND d.ref.destination = :refDest
       AND d.availDate between :lowDate and :highDateIf I'm misunderstanding your intent, let me know and I'll try to help you resolve the problem.

  • Design problem about repreatable entity relationships

    Hi all!
    As I design the data model (let's name it the ERD, no matter the name is quite unfashonable), I have found almost identical structures of entities and relationships between them, but playing completely different roles in the semantics of the model.
    It obviously makes no sense to implement all such entities separately as the Entity EJB as they are to share most of the fields and methods, but I found no "handsome" solution when trying to implement them as sets of classes and interfaces forming "the abstract EJBs", and then by putting the conrete classes and complementary interfaces at the final packages to create "concrete EJBs". The problem was about types returned by the createXXX and findXXX methods, because they had to return the "abstract" EJBs but the EJB programming contract forces them to return the "concrete" ones, that are unknown to me when defining the "abstract ones". So it cancels the sense for creating them this way. It was also unclear how to operate the relationships in such model.
    The idea was:
    1. I define BaseSthLocalHome extends EJBLocalHome
    2. I define BaseSthLocal extends EJBLocalObject
    3. I define BaseSthBean implements EntityBean
    ... this way I have the "abstract bean", and then I can create many:
    SthOneLocalHome extends BaseSthLocalHome,
    SthOneLocal extends BaseSthLocal,
    SthOneBean extends BaseSthBean ... to have the first "concrete" EJB,
    SthTwoLocalHome extends BaseSthLocalHome... and so on to create the second, third and all the next "concrete" EJBs.
    Anyway, it did not work fine as I defined createXXX and findXXX methods at the BaseSthLocalHome interface - it made sense, because those methods did not depend on the other entities.
    Has anyone some idea of how to solve the design problem? Currently we are at very beginning of the project, so we have some "case study" time, and I would appreciate any solution: redesign of the data model, extraction of new EJB modules or any use of the objective inheritance.
    Thanks in advance!
    Marcin Gawlik

    Again me - I now it is a bad idea to reply for own messages, but I have just checked a new idea:
    The problem was about re-using the same components in different roles. I tried to do that by creating subclasses of the EJB classes, but it did not work. So I tried to define multiple entity EJBs that have the same class.
    Considering the given example, it would look:
    1. public interface BaseSthLocalHome extends EJBLocalHome
    2. public interface BaseSthLocal extends EJBLocalObject
    3. public abstract class BaseSthBean implements EntityBean
    ... then I created the deployment descriptor that deploys this pack of class and interfaces as three separate CMP Entity Beans:
    1. deploy BaseSthBean as the SthOne CMP entity EJB
    2. deploy BaseSthBean as the SthTwo CMP entity EJB
    3. ... and so one
    The question is: IS THERE ANY CONTRA FOR THIS WAY OF DEPLOYING EJBS? Is there any reason for not to use the same class and its complementary interfaces many times to create many separate enity EJBs working within the same EJB module?
    Thanks in advance!
    Gaw

  • Problem with 1:many relationship between entity beans.

    Hi All!
    I have two tables TMP_GROUP and TMP_EMPLOYEE with following fields:
    TMP_GROUP: ID, CAPTION, COMMENT, STATUS.
    TMP_EMPLOYEE: ID, LOGIN, GROUP_ID.
    For this tables i create two entity beans GROUP and EMPLOYEE respectively.
    The relationship looks like this
    descriptor ejb.xml:
    <ejb-relation>
                <description>description</description>
                <ejb-relation-name>employeesOfGroup</ejb-relation-name>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.GroupBean</ejb-relationship-role-name>
                    <multiplicity>One</multiplicity>
                    <relationship-role-source>
                        <ejb-name>GroupBean</ejb-name>
                    </relationship-role-source>
                    <cmr-field>
                        <cmr-field-name>employees</cmr-field-name>
                        <cmr-field-type>java.util.Collection</cmr-field-type>
                    </cmr-field>
                </ejb-relationship-role>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.EmployeeBean</ejb-relationship-role-name>
                    <multiplicity>Many</multiplicity>
                    <relationship-role-source>
                        <ejb-name>EmployeeBean</ejb-name>
                    </relationship-role-source>
                </ejb-relationship-role>
            </ejb-relation>
    descriptor persistent.xml:
    <table-relation>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>GroupBean</ejb-name>
                        <cmr-field>employees</cmr-field>
                   </table-relationship-role>
                   <table-relationship-role
                        key-type="NoKey">
                        <ejb-name>EmployeeBean</ejb-name>
                        <fk-column>
                             <column-name>GROUP_ID</column-name>
                             <pk-field-name>ejb_pk</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
              </table-relation>
    Now i implement business method:
    public Long addEmployee(String login, long groupId) {
              Long result;
              try {
                   EmployeeLocal employee = employeeHome.create(login);
                   GroupLocal group =
                        groupHome.findByPrimaryKey(new Long(groupId));
                   Collection employees = group.getEmployees();
                   employees.add(employee);
                   result = (Long) employee.getPrimaryKey();
              } catch (CreateException ex) {
                   result = new Long(0);
              } catch (FinderException ex) {
                   result = new Long(0);
              return result;
    When i call this method from web service, the following exception is raised:
    com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception in method com.mypackage.GroupLocalHomeImpl0.findByPrimaryKey(java.lang.Object).
    P.S.
    1) I have transaction attribute set to "Required" for all methods of all beans
    2) I have unique index for each table:
    TMP_GROUP_I1: CAPTION
    TMP_EMPLOYEE_I1: LOGIN (however i think GROUP_ID must be added here too)
    3) I tried many:many relationship with this tables and it works fine
    4) I try another implementation of addEmployee method with
    EmployeeLocal employee = employeeHome.create(login, groupId);
    without using GroupLocal cmr-field and GroupLocalHome findByPrimaryKey method, the result is same error.
    Can somebody help me with this problem?
    Thanks in advance.
    Best regards, Abramov Andrey.

    I have posted excerpts from my orion-ejb-jar.xml file in this posting: Problem mapping a 1:M relationship between two entity EJBs w/ a compound PK
    Sorry for the duplicate postings, but I was getting errors on the submission.
    April

  • Problem with JPA Implementations and SQL BIGINT in primary keys

    I have a general Question about the mapping of the SQL datatype BIGINT. I discovered, that there are some different behaviour depending on the JPA implementation. I tested with TopLink Essentials (working) and with Hibernate (not working).
    Here is the case:
    Table definition:
    /*==============================================================*/
    /* Table: CmdQueueIn */
    /*==============================================================*/
    create table MTRACKER.CmdQueueIn
    CmdQueueInId bigint not null global autoincrement,
    Type int,
    Cmd varchar(2048),
    CmdState int,
    MLUser bigint not null,
    ExecutionTime timestamp,
    FinishTime timestamp,
    ExecutionServer varchar(64),
    ScheduleString varchar(64),
    RetryCount int,
    ResultMessage varchar(256),
    RecordState int not null default 1,
    CDate timestamp not null default current timestamp,
    MDate timestamp not null default current timestamp,
    constraint PK_CMDQUEUEIN primary key (CmdQueueInId)
    The java class for this table has the following annotation for the primary key field:
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "CmdQueueInId", nullable = false)
    private BigInteger cmdQueueInId;
    When using hibernate 3.2.1 as JPA provider I get the following exception:
    avax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short or string
    at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
    at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:218)
    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 org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:176)
    at $Proxy16.persist(Unknown Source)
    at com.trixpert.dao.CmdQueueInDAO.save(CmdQueueInDAO.java:46)
    at com.trixpert.test.dao.CmdQueueInDAOTest.testCreateNewCmd(CmdQueueInDAOTest.java:50)
    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 junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at
    Caused by: org.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short or string
    at org.hibernate.id.IdentifierGeneratorFactory.get(IdentifierGeneratorFactory.java:59)
    at org.hibernate.id.IdentifierGeneratorFactory.getGeneratedIdentity(IdentifierGeneratorFactory.java:35)
    at org.hibernate.id.IdentityGenerator$BasicDelegate.getResult(IdentityGenerator.java:157)
    at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:57)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2108)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2588)
    at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
    at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290)
    at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
    at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:131)
    at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:87)
    at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38)
    at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
    at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
    at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)
    at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:212)
    ... 34 more
    This means, that their ID generator does not support java.math.BigInteger as datatype.
    But the code works if I take TopLink essentials as JPA Provider.
    Looking at the spec shows the following:
    In chapter 2.1.4 "If generated primary keys are used, only integral types will be portable." Integral datatypes are byte, short, int, long and char. This would mean, that the Hibernate implementation fits the spec but there seem to be a problem in general with BIGINT datatypes.
    I use a SYBASE database. There it is possible to declare a UNSIGNED BIGINT. The range of numbers is therefore 0 - 2^64 - 1. Since in Java a long is always signed it would mean its range is from -2^63 -1 to 2^63 -1. So a mapping of BIGINT to java.lang.long could result in an overflow.
    The interesting thing is, that I used NetBeans to reverse engineer an existing database schema. It generated for all Primary Keys of Type BIGINT automatically a java.math.BigInteger. But for other fields (not being keys) it mapped BIGINTs to java.lang.long.
    It looks like there are some problems with either the spec itself or the implementation of it. While TopLink seems to handle the problem correctly, Hibernate doesn't. But Hibernate seems to fulfill the spec.
    Is anybody familiar with the Spec reading this and can elaborate a little about this situation?
    Many thanks for your input and feedback.
    Tom

    Not sure if I clearly understand your issue, would be good if you can explain it a bit more clearly.
    "I select a value from LOV and this value don't refresh in the view"
    If you mean ViewObject, check if autoSubmit property is set to true.
    Amit

  • Problem with JPA @Embeddable class field in  @Embedded

    I have a Embeddable class and Embadded in all of my JPA Entities, the version(in DBUniqueId) field is mandatory for some JPA Entities and for others it should not be present.
    My DBUser.java JPA Entity shouldn't have version field(DBUser table doesn't have one) and so I didn't include it in @AttributeOverrides of DBUser.java. when I try to run the JPA query it results in exception
    Query:
    List<DBUser> userList = (List<DBUser>)entityManager.createQuery(SELECT u FROM DBUser u WHERE u.userId.root=?1 AND u.userId.extension=?2).setParameter(1,"root1").setParameter(2,"ext1").getResultList ();
    And The Exception is:
    ---- Begin backtrace for Nested Throwables
    java.sql.SQLException: ORA-00904: "T0"."VERSION": invalid identifier
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:74)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:131)
    How do I inform to JPA Entity to ignore only the version field of the Embeddable in my JPA Entity @Embedded place.
    So the above query can successful. Thank You!
    Please guide me to solve this problem.
    @Embeddable
    @MappedSuperclass
    public class DBUniqueId implements Serializable {
    * serialVersionUID.
    private static final long serialVersionUID = 8903598739796209331L;
    * root.
    private String root;
    * extension.
    private String extension;
    * version.
    private String version;
         //Getters & Setters
    @Entity
    @Table(name = "MyTable", schema = "MySchema")
    public class DBUser implements Serializable {
    * unique user id.
    private DBUniqueId uniqueUserId;
    * Get the unique user id.
    * @return <code>DBUniqueId</code> - unique person id
    @Embedded
    @AttributeOverrides( {
    @AttributeOverride(name = "root", column = @Column(name = "LUSR02_ID_ROOT", nullable = true, length = 50)),
    @AttributeOverride(name = "extension", column = @Column(name = "LUSR02_ID_EXT", nullable = true, length = 50))
    public DBUniqueId getUserId () {
    return uniqueUserId;
    * set user unique id.
    * @param uniqueId - unique id of the person
    public void setUserId (final DBUniqueId uniqueId) {
    this.uniqueUserId = uniqueId;
    }

    Sudeep Naidu wrote:
    Hello gimbal2,
    Thanks for your response...
    In my project I have created a class with name DBVersionUniqueId but my lead said no to it.
    Only DBUniqueId should be used and make it work with or with out version fields.
    I tried experimenting around, but didn't succeed.
    Please Suggest some solution to make it work with DBUniqueId class.
    Thank You.No, let your lead write the code. He/she seems to be the expert. I certainly have no clue how to do it and honestly I also cannot find any reason why it should be possible. Let me put what is required in other words:
    - you have an entity with three properties, all of which are not transient. This means these properties map to three columns in the database according to the JPA specs.
    - you have a table with only two properties
    - you must and you shall use the object with three properties but at the same time one of the fields must all of a sudden be ignored by the persistence provider
    It makes no sense to want to do that.
    Correct answer: create a new object with only the two fields so the database and the object model match exactly
    Wrong answer: try to create workarounds that in six months time nobody is going to understand why the hell it was done that way

  • Problem deploying JPA project

    When deploying an ear containing a war with a persitence archive in its WEB-INF/lib, I get a deploy error. The error in the opmn log seems to indicate a problem with parsing some xml file, but I can't seem to find a problem with the persitence.xml. This seems to work correctly using the embedded version of OC4J included with Jdevelper but fails when deploying to a clustered App server instance on linux.
    The application server version is 10.1.3.1 which matches the version of Jdev I'm using.
    thanks in advance.
    The persistence archive contains a persistence.xml under its META-INF with these contents
    <?xml version="1.0" encoding="windows-1252" ?>
    <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name="Model" transaction-type="JTA">
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    <jta-data-source>jdbc/web</jta-data-source>
    <properties>
    <property name="toplink.session-name" value="Model"/>
    <property name="toplink.logging.level" value="FINE"/>
    <property name="toplink.logging.timestamp" value="true"/>
    <property name="toplink.logging.session" value="true"/>
    <property name="toplink.logging.thread" value="true"/>
    <property name="toplink.logging.exceptions" value="true"/>
    <property name="toplink.target-database" value="Oracle"/>
    </properties>
    </persistence-unit>
    </persistence>
    Deploy Error
    Operation failed with error:
    [fcmanagement:FCManagement] - Exception creating EntityManagerFactory using PersistenceProvider class oracle.toplink.essentials.PersistenceProvider for persistence unit Model.
    In the opmn log I see this stack trace
    <Line 1, Column 1>: XML-20108: (Fatal Error) Start of root element expected.
    07/06/20 15:37:58 oracle.oc4j.admin.internal.DeployerException: [fcmanagement:FCManagement] - Exception creating EntityManagerFactory using PersistenceProvider class oracle.toplink.essentials.PersistenceProvider for persistence unit Model.
    07/06/20 15:37:58 at com.evermind.server.ejb.exception.DeploymentException.exceptionCreatingEntityManagerFactory(DeploymentException.java:130)
    07/06/20 15:37:58 at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.createContainerEntityManagerFactory(PersistenceUnitManagerImpl.java:197)
    07/06/20 15:37:58 at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.initializePersistenceUnit(PersistenceUnitManagerImpl.java:159)
    07/06/20 15:37:58 at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.initialize(PersistenceUnitManagerImpl.java:86)
    07/06/20 15:37:58 at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:733)
    07/06/20 15:37:58 at com.evermind.server.ApplicationStateRunning.getHttpApplication(ApplicationStateRunning.java:414)
    07/06/20 15:37:58 at com.evermind.server.Application.getHttpApplication(Application.java:545)
    07/06/20 15:37:58 at com.evermind.server.http.HttpSite$HttpApplicationRunTimeReference.createHttpApplicationFromReference(HttpSite.java:1990)
    07/06/20 15:37:58 at com.evermind.server.http.HttpSite$HttpApplicationRunTimeReference.<init>(HttpSite.java:1909)
    07/06/20 15:37:58 at com.evermind.server.http.HttpSite.addHttpApplication(HttpSite.java:1606)
    07/06/20 15:37:58 at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:238)
    07/06/20 15:37:58 at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:99)
    07/06/20 15:37:58 at oracle.oc4j.admin.internal.ApplicationDeployer.bindWebApp(ApplicationDeployer.java:547)
    07/06/20 15:37:58 at oracle.oc4j.admin.internal.ApplicationDeployer.doDeploy(ApplicationDeployer.java:202)
    07/06/20 15:37:58 at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:93)
    07/06/20 15:37:58 at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun(OC4JDeployerRunnable.java:52)
    07/06/20 15:37:58 at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRunnable.run(DeployerRunnable.java:81)
    07/06/20 15:37:58 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
    07/06/20 15:37:58 at java.lang.Thread.run(Thread.java:595)
    07/06/20 15:37:58 WARNING: DeployerRunnable.run [fcmanagement:FCManagement] - Exception creating EntityManagerFactory using PersistenceProvider class oracle.toplink.essentials.PersistenceProvider for persistence unit Model.oracle.oc4j.admin.internal.DeployerException: [fcmanagement:FCManagement] - Exception creating EntityManagerFactory using PersistenceProvider class oracle.toplink.essentials.PersistenceProvider for persistence unit Model.
    at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:126)
    at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun(OC4JDeployerRunnable.java:52)
    at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRunnable.run(DeployerRunnable.java:81)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
    at java.lang.Thread.run(Thread.java:595)

    I tried repackaging the ear. Instead of including the persistence archive in the web-inf/lib of the war, I created an EJB jar with the jpa project in it.
    The application.xml now deploys that as an ejb module along with the war.
    The deploy error is a little different now, it specifies a missing class, Missing class: oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.
    I'm assuming that this class is in the toplink-essentials.jar. Should the toplink-essential.jar be packaged in the ear?
    Again this is being deployed to a 10.1.3.1 Application server.
    thanks
    Joel
    Here is to full error message
    [inapp03.inapp03/fastconnecttst] 07/06/21 11:54:47 Notification ==>Operation failed with error:
    Missing class: oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
    Dependent class: com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl
    Loader: oc4j:10.1.3
    Code-Source: /usr01/app/oracle/product/10.1.3/OracleAS_1/j2ee/home/lib/oc4j-internal.jar
    Configuration: <code-source> in META-INF/boot.xml in /usr01/app/oracle/product/10.1.3/OracleAS_1/j2ee/home/oc4j.jar
    This load was initiated at fcmanagement.root:0.0.0 using the Class.forName() method.
    The missing class is not available from any code-source or loader in the system.
    [Summary] There are total 2 instances in the operation.
    [Summary] Operation failed on inapp04.inapp04/fastconnecttst
    [Summary] Operation failed on inapp03.inapp03/fastconnecttst
    [Summary] Operation on cluster FAILED since 2 instanced failed!
    Deploy error: Deploy error: Operation failed with error:
    Missing class: oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
    Dependent class: com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl
    Loader: oc4j:10.1.3
    Code-Source: /usr01/app/oracle/product/10.1.3/OracleAS_1/j2ee/home/lib/oc4j-internal.jar
    Configuration: <code-source> in META-INF/boot.xml in /usr01/app/oracle/product/10.1.3/OracleAS_1/j2ee/home/oc4j.jar
    This load was initiated at fcmanagement.root:0.0.0 using the Class.forName() method.
    The missing class is not available from any code-source or loader in the system.

  • Owner in ManyToMany Relationships

    Hello all,
    I need to create a many to many relation between some roles and some policies.
    I do not want to cascade PERSIST, or REMOVE. So when creating the relation both the Policies and Roles involved are in the database.
    Also the relation are done in a stand alone client, so the objects become dettached.
    So this is the issue:
    In the first case the Role entity is the owner.
    On the client side:
    role.getPolicies().add( policy );
    remoteSessionBean.updateObject( role ); //executes remotely on the server.All is fine. The role/policy association in saved into the database.
    Now if do:
    policy.getRoles().add( role );
    remoteSessionBean.updateObject( policy ); The relation is not created in the database :(.
    If I make the policy object the owner of the manytomany then the two exemple are reversed: it works when updating the relation via policy, but it does not work when updated via role.
    Is there any way to make it work both at the same time. The GUI allows the user to eiter add roles to a policy and then save the policy, or to add policy to a roles and then save the roles.
    Thank you for your time,
    - Ilie

    The Hibernate documentation states that in a bidirectional relationship both entities need to be updated.
    So the code should look somethig like:
    role.getPolicies().add(  policy );
    policy.getRoles().add( role );
    remoteSessionBean.update( role );
    remoteSessionBean.update( policy );Unless anyone has a better idea this is the only way...

  • Problem with JPA + Hibernate Validator when performing update

    When I try to insert an new entity with a validation problem, Hibernate Validator works normally, but when I try to update an entity the InvalidStateException is not thrown when persist() is called, so when commit() is called a RollbackException is thrown.
    I'm using the latest versions of the hibernate libraries. The problem happened with JSF(NetBeans 6 VWP) and Java SE.
    Sample code:
          EntityManagerFactory emf = Persistence.createEntityManagerFactory("HibernateValidatorTest");        
          EntityManager em = emf.createEntityManager ();       
          ScfaqAssunto assunto = em.find(ScfaqAssunto.class, 2); // new ScfaqAssunto() works normally
          assunto.setAssunto(""); // the property assunto is with @NotEmpty              
          try
             em.getTransaction().begin();
             em.persist(assunto);
             em.getTransaction().commit();
          catch(InvalidStateException e)
             if( em.getTransaction().isActive())
                em.getTransaction().rollback();
             for(InvalidValue invalidValue : e.getInvalidValues())
                System.out.println (invalidValue.getMessage());
          catch(Exception e)
             if(em.getTransaction().isActive())
                em.getTransaction().rollback();
             System.out.println(e.getMessage());
          finally
             em.close();
          } Thanks for any help,
    Felipe

    Hi Thomas
    I loose hours with this problem
    there is a problem with toplink lib version
    just download toplink librairies at http://www.oracle.com/technology/products/ias/toplink/jpa/index.html
    replace oldest in $Glassfishdir\lib
    It have to works
    tested on postGres and Derby
    Can netbeans update center fix this problem?

  • Problem with Contact person Relationship...

    Hi All,
    I got the following issue.
    "Contact person relationship already exists between partners &1 and &2...."
    For this, I have checked the Business partners, tables and GUID's in R/3 and as well as in CRM and checked BP consistency fix...
    I have seen change history also, this problem occured to BUPA_REL B.Doc type. While after doing the Synchronization also i am getting errors like  "BP already exists and Partner (GUID No) errors occured...
    Please advise regarding this issue...
    Thanks in Advance.....

    Hello,
    You are leaving an unmanaged object in the tree when the transaction attempts to commit. If you are going to persist a new VerticalUser, it must reference an existing or managed VerticalHommeArt.
    If the VerticalUser references a new VerticalHommeArt, either persist the VerticalHommeArt before or set the verticalHommeArt relationship to cascade persist
    Best Regards,
    Chris

  • Help with JPA Inheritance Relationship Mapping

    Perhaps someone can help with this. I'm trying to figure out how to map what seems like a simple data model using JPA. But it is not working.
    @Entity
    public class Account {
        @OneToOne(cascade=CascadeType.ALL)
        private AbstractPaymentMethod paymentMethod;
    @Entity
    @MappedSuperClass
    @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
    @DiscriminatorColumn(name="__CLASS__", discriminatorType=DiscriminatorType.STRING, length=20)
    @DiscriminatorValue("AbstractPaymentMethod")
    public abstract class AbstractPaymentMethod {
    @Entity
    @Table(name="payment_method")
    @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
    @DiscriminatorColumn(name="__CLASS__", discriminatorType=DiscriminatorType.STRING, length=20)
    @DiscriminatorValue("CreditCardPaymentMethod")
    @SuppressWarnings("serial")
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
    public class CreditCardPaymentMethod extends AbstractPaymentMethod {
        @Column
        private String expirationDate;
    }The problem is, when I add a CreditCardPaymentMethod to an account like this...
    Account account = new Account();
    CreditCardPaymentMethod m = new CreditCardPaymentMethod();
    account.setPaymentMethod(m);
    em.persiste(account);... The entity manager attempts to save account.creditCardPaymentMethod as an AbstractPaymentMethod.
    Surely I'm doing something horribly wrong. Is there something I'm missing here?
    Thanks for any help.

    Thank you! You saved my life. After removing @MappedSuperClass, all is well.
    The entity manager is now saving my CreditCardPaymentMethod objects as CreditCardPaymentMethod classes instead of AbstractPaymentMethod classes.

  • Update bidirectional ManyToMany relationship

    Hello,
    we have a bidirectional man-to-many relationship (User - Course).
    Now we want users to join courses. How to update the relationship correctly?
    If I do
    course.getUsers().add(user);
    entityManager.merge(course);The user is not updated. Also if a add course to the users course list but only merge the course.
    And if I do
    course.getUsers().add(user);
    user.getCourses().add(course);
    entityManager.merge(course);
    entityManager.merge(user);I get a duplicate key exception, because jpa tries to add the entry in the join table twice.
    How to do this right?
    thanks
    Dirk

    No, they are not managed by the jpa at this moment.
    They come from a jsf application, that have serialized the course (into a selectbox).
    So simply adding the user to the coures is not enough.
    I've tried merging both bevore adding, to get them managed. But this doesn't work too. (The user is in the courses user list, but the course not in the users courses list)
    Edited by: Freak.2k on Jun 12, 2009 9:34 AM

  • Problem with Foreign Key relationships in SAP R/3 4.7

    Hi Experts,
    I am trying to create a foreign key relationship between 2 transparent tables in SAP R/3 4.7
    Table 1:ZAAVNDR (MANDT (pk), VENDORNO (pk), NAME, REGION, COUNTRY (fk)) Foreign Key Table
    Table 2: ZAAVNDRREF(MANDT(pk), COUNTRY (pk)) ---Check table
    I have added few valid countries in check table but when I am adding some records in foreign key table with invalid countries these records are not being restricted and are still successfully going into the table.
    Could any one please help in this.
    Thanks in anticipation.
    -Amit

    Hi Sandra,
    Many thanks for your response and providing time of yours.
    Now, I have done exactly the same thing, but still it is the same.
    I have created two new tables as below:
    ZAAVREF (Check table)
    MANDT (PK)
    COUNTRY (PK) Domain:ZAACOUNT (CHAR 10)
    ZAAV1 (Foreign key table)
    MANDT (PK)
    COUNTRY (PK) Domain:ZAACOUNT (CHAR 10)
    Then I have created FK on country of foreign key table ZAAV1 and then SE16 (for table ZAAVREF)->Create Entries-> Entered values for Country only->Save....Records entered with valid Country values.
    After that SE16 (for table ZAAV1)->Create Entries-->Entered an Invalid country->Save->Still the record entered to the Database successfully....
    Could you please let me know where I am going wrong.
    I am using SAP R/3 4.7 and creating tables using Tools->ABAP Workbench->Development->ABAP dictionary

  • Problem with master/detail relationship

    Two tables :
    Master_table:
    Customer_no primary key
    Buyer_seller_type primary key
    Product_code primary key
    Detail_table
    Branch primary key
    Customer_no primary key
    I altered detail_table and added 2 more primary key fields:
    Buyer_seller_type primary key--
    Product_code primary key.
    Now I have to change the existing fmb according.
    I have maintained master/detail relationship for these 2 tables in the form.
    When I run this form and Try to save the date . I am getting error like
    Cannot insert null into buyer_seller_type field ie my new column.
    Insert into detail_table (branch,customer_type) values (:1,:2) ;
    I have maintained master/detail relationship. And what r the others properties I have to set to overcome this .
    my requirement is query should be like this:
    insert into detail_table (branch,customer_type,buyer_seller_type,product_code) values (:1,:2,:3,:4) ;
    how can i do this.
    I am using forms 6.
    plz its very urgent..plz help me.
    advance thanks

    Set following item property under Data node for both the new added column in detail table:
    Copy Value from Item:
    Enter <master_table_name.item_name>
    Regards,
    Hassan

Maybe you are looking for

  • How can I copy, paste and edit a phone number?

    If I copy a phone number then paste it, how can I edit the pasted number? For example, my phone has an Irish SIM. If I am in the UK and copy a UK phone number from an email signature it will typically be in local format i.e. 0208 456 7890. I need to

  • Invoiced qty field in 2lis_02_scl

    I am extracting data from 2lis_02_scl in this we have a keyfigure called invoice qty,so my user wants this value to be extracted from mseg table filed menge .First of all I want to know the invoice qty figure is coming from which table & the data of

  • Create dynamic internal table with deep structure;cell coloring dynamic ALV

    Hi, My requirement is to do cell colouring for a dynamic ALV. So I am creating a dynamic internal table using the following method.   CALL METHOD cl_alv_table_create=>create_dynamic_table     EXPORTING       it_fieldcatalog = i_fieldcatalog[]     IMP

  • All timer jobs don't start (paused in check job status)

    Hello, Some bad things have happend to our SharePoint Server 2010. All timer jobs suddenly stopped running. The last time they ran successfully was 09/26/11. Since that time all jobs have been scheduled to run according to their schedule but don't ac

  • Internet links doesn't work anymore within my Outlook

    My internet links within my Outlook doesn't work anymore when I click on the link (I got a system problem). Anyone who knows what settings I need to do? Thanks