Many-to-one relationship using annotations in hibernates...

my pojo class is M_Product_Category
package com.netree.model;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.OneToMany;
import javax.persistence.JoinColumn;
@Entity
@Table(name="m_product_category")
public class M_Product_Category implements Serializable{
     @Id
     @Column(name="MPC_ID")
     @GeneratedValue
     private int mpc_Id;
     @Column(name="IsActive")
     private int isActive;
     @Column(name="Category_Name")
     private String category_Name;
     @Column(name="Category_Description")
     private String category_Description;
     @Column(name="Parent_MPC_ID")
     private int parent_MPC_ID;
     public M_Product_Category(){
     public M_Product_Category(int mpc_Id, int isActive, String category_Name,
               String category_Description, int parent_MPC_ID) {
          super();
          this.mpc_Id = mpc_Id;
          this.isActive = isActive;
          this.category_Name = category_Name;
          this.category_Description = category_Description;
          this.parent_MPC_ID = parent_MPC_ID;
     public int getMpc_Id() {
          return mpc_Id;
     public void setMpc_Id(int mpc_Id) {
          this.mpc_Id = mpc_Id;
     public int getIsActive() {
          return isActive;
     public void setIsActive(int isActive) {
          this.isActive = isActive;
     public String getCategory_Name() {
          return category_Name;
     public void setCategory_Name(String category_Name) {
          this.category_Name = category_Name;
     public String getCategory_Description() {
          return category_Description;
     public void setCategory_Description(String category_Description) {
          this.category_Description = category_Description;
     @OneToMany(cascade=CascadeType.ALL)
     @JoinColumn(name="Parent_MPC_ID", referencedColumnName="MPC_ID")
     public int getParent_MPC_ID() {
          return parent_MPC_ID;
     public void setParent_MPC_ID(int parent_MPC_ID) {
          this.parent_MPC_ID = parent_MPC_ID;
This is anothe pojo class i.e., ProductMaster:
package com.netree.model;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "M_Product_Master")
public class ProductMaster implements Serializable {
     @Id
     @GeneratedValue
     @Column(name = "MPM_ID")
     private int mpmID;
     @Column(name = "Product_Name")
     private String productName;
     @Column(name = "Product_Description")
     private String productDescription;
     @Column(name = "Standard_Cost")
     private String price;
     @Column(name = "Image_URL_Big")
     private String image;
     @Column(name = "MPC_ID")
     private int mpc_id;
     public int getMpc_id() {
          return mpc_id;
     public void setMpc_id(int mpc_id) {
          this.mpc_id = mpc_id;
     private M_Product_Category product_Category;
     @ManyToOne(cascade = CascadeType.ALL)
     @JoinColumn(name = "mpc_id", referencedColumnName = "MPC_ID")
     public M_Product_Category getProduct_Category() {
          return product_Category;
     public void setProduct_Category(M_Product_Category product_Category) {
          this.product_Category = product_Category;
     public int getMpmID() {
          return mpmID;
     public void setMpmID(int mpmID) {
          this.mpmID = mpmID;
     public String getProductName() {
          return productName;
     public void setProductName(String productName) {
          this.productName = productName;
     public String getProductDescription() {
          return productDescription;
     public void setProductDescription(String productDescription) {
          this.productDescription = productDescription;
     public String getPrice() {
          return price;
     public void setPrice(String price) {
          this.price = price;
     public String getImage() {
          return image;
     public void setImage(String image) {
          this.image = image;
util class...
package com.netree.Util;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class HibernateUtil {
     public static SessionFactory getSessionFactory() {
          System.out.println("sessionFactory");
          AnnotationConfiguration annotationConfiguration = new AnnotationConfiguration();
          System.out.println("annotationConfiguration");
          annotationConfiguration=annotationConfiguration.configure("com/netree/Cfg/Hibernate.cfg.xml");
          SessionFactory sessionFactory = annotationConfiguration.buildSessionFactory();
          return sessionFactory;
package com.netree.DaoImpl;
import java.util.Iterator;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import com.netree.Util.HibernateUtil;
import com.netree.model.ProductMaster;
public class ProductMasterImpl {
public static void main(String args[]) {
                         try{
                              System.out.println("sessionFactory starts");
          SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
          System.out.println("sessionFactory ends");
          Session session=sessionFactory.getCurrentSession();
                              Transaction transaction=session.beginTransaction();
     Criteria ctr=session.createCriteria(ProductMaster.class).add(Restrictions.eq("mpc_id",new Integer(39)));
     List<ProductMaster> list=ctr.list();
               @SuppressWarnings("rawtypes")
                              Iterator iterator = list.iterator();
               while (iterator.hasNext()) {
                    ProductMaster productMaster = (ProductMaster) iterator.next();
System.out.println(productMaster.getMpmID());
System.out.println(productMaster.getProductName());
System.out.println(productMaster.getProductDescription());
System.out.println(productMaster.getPrice());
System.out.println(productMaster.getImage());
System.out.println(productMaster.getProduct_Category().getMpc_Id());
System.out.println(productMaster.getProduct_Category().getCategoryName());
System.out.println(productMaster.getProduct_Category().getCategory_Description());
               session.close();
     catch(Exception ex){
     System.out.println(ex.getMessage());
                    finally{
Already i have two tables in database with the suitable records... I want to retrieve the data by using MPC_ID from both tables....
when i run this program i am getting query but it is showing exception i.e....
Hibernate: select this_.MPM_ID as MPM1_1_0_, this_.Image_URL_Big as Image2_1_0_, this_.MPC_ID as MPC3_1_0_, this_.Standard_Cost as Standard4_1_0_, this_.Product_Description as Product5_1_0_, this_.Product_Name as Product6_1_0_, this_.product_Category as product7_1_0_ from M_Product_Master this_ where this_.MPC_ID=?
could not execute query
could u pls help me in this regard.....

in the cube do you have both of these values
PT02 211886
PT02 211887
or its always either one of them. I dont think changing your cube design would prove any helpful in this scenario. I believe its more of a data issue than the design issue. You would need to change the way the data is entered into the cube with the different measurement assigned to the unit.
on a second thought(I understand that you dont have a luxury to change the cube design),  when you say you can see diff measurement type assigned to one unit in the masterdata, you can make the unit attribute as a navigational attribute in both the IO and cube. And just map measurent type in the update rules and derive the units from the masterdata table in the report.... does it make sense?
Message was edited by:
        voodi

Similar Messages

  • Many-to-one relationships

    I'm trying to implement a many-to-one relationship similar to the one, for example, between an OrderLineItem and a Product.
    I managed to create the beans and define the relationship using deploytool.
    What I'm trying to understand is how can I prevent a Product instance from being deleted when it is involved in the relationship described above?
    Currently, under Sun's reference implementation server, I am allowed to delete a Product even if there are OrderLineItems that reference it.
    There is one line printed out in the window running j2ee -verbose:
    com.sun.ejb.containers.EntityContainer$EJBTxKey
    The record in the Product table is deleted nonetheless.
    Another weird thing is that the server does not allow me to deploy two beans involved in a many-to-one relationships with the Product bean if they are using the same CMR field name. What I get is a compilation error at the deployment time.
    I'd appreciate any input.

    They way I handle this is to hide the creation/manipulation/deletion of the bean behind a manager - for example a singleton session bean. I NEVER allow the direct creation/deletion of entity beans except through manager classes. This is quite a common J2EE pattern, whose name escapes me at the moment.
    Your manager would have a method like delete(int productId), which would delete the matching Product entity bean, and would then search the OrderLineItem beans for the matching Product primary key.

  • Many to one relationships strange behavior

    I have a problem with two many to one relationships.
    The problem appears from the dirty mechanism of cmr/cmp fields.
    When I have two “many-to-one” relationships ex:
    A n..1 B
    A n..1 C
    Navigability: B -> A
              A <-> C
    When I put in ejb-jar.xml the B to A relation first, the bugs appear. The dirty mechanism work chaotic. The problem is in the generated code for the PersistenceManager and Wrapper of the A bean.
    In the Wrapper the only fields with dirty mecansim are the real fields from bean which are navigable. In the PersistenceManager class are the same fields like in the BeanWrapper plus the fake fields for relationship. But the fake fields are intercalated with real fields and the dirty flag values are not the same with the dirty flags from BeanWrapper. Result: chaotic updates.
    Solution(workaround – not elegant): put first the relation which has navigability from A to C and second A to B.

    They way I handle this is to hide the creation/manipulation/deletion of the bean behind a manager - for example a singleton session bean. I NEVER allow the direct creation/deletion of entity beans except through manager classes. This is quite a common J2EE pattern, whose name escapes me at the moment.
    Your manager would have a method like delete(int productId), which would delete the matching Product entity bean, and would then search the OrderLineItem beans for the matching Product primary key.

  • SD Billing document many to one relationship with sales order

    Hi experts,
    We have a scenario where we have done collective billing for some time.  So, obviously we have from sales order to billing one to many relationship.  Meaning, one sales order has many billing docs. 
    Now, we want to merge the sales order (VBAP) data with billing data (VBRP).  But, we want to take only one billing document which is appropriate.  
    For example, we have a sales order, corresponding that we have a billing debit memo followed by a cancellation, followed by another debit memo.  In this case we have to take the third debit memo as it is the latest and the first one has a cancellation.
    We will know alll this through VA02 Tcode.  However, we want to derive this logic off of the above tables.  We are actaully clue less as to how to pick up the right billing doc from VBRP for a sales order out of many.
    Please post ur replies.
    Thanks.

    Hi Jain,
    Thanks for the reply.  The sort out mechanism may not be the one we are looking for.  There may be several DIFFERENT billing docs for a single sales doc.  More over, these billing docs may have been created on the same date.  So, what we are looking for is a fied or information like XBLNR in VBAP with which we can for sure eliminate all other billing docs and cancellations against them, for exmaple, and pickup the right billing doc alone.
    I relly appreciate your efforts.
    Thanks.

  • Foreign key in many to one relationship causes redunency

    Hi
    suppose I have two tables
    A and B
    Table A has a primary key A_PK number
    Table B has a primary key B_PK number
    The relation between two tables is M to One
    if B_PK is foreign key on table A
    then it causes redunency
    A_PK B_PK
    1 1
    2 1
    so what the best way to solve like this problem?
    thanks

    VANPERSIE wrote:
    Hi
    suppose I have two tables
    A and B
    Table A has a primary key A_PK number
    Table B has a primary key B_PK number
    The relation between two tables is M to One
    if B_PK is foreign key on table A
    then it causes redunency
    A_PK B_PK
    1 1
    2 1
    so what the best way to solve like this problem?
    thanksIt's not sure from your description exactly how/where/what columns are involved in the FK relationship. You either have no problem, or your problem is that you have two tables with the same PK, meaning you haven't normalized your design.
    As suggested, post actual table defs, not just a vague description.

  • Many to one relationship !

    Hi All,
    i have one query having Rental Unit and Measurements.
    in reality one Rental unit has many measurements but when i run the query it shows me only one measurements per Rental Until!
    any clue ? how can i get all the measurements for each rental unit ?
    please help.

    in the cube do you have both of these values
    PT02 211886
    PT02 211887
    or its always either one of them. I dont think changing your cube design would prove any helpful in this scenario. I believe its more of a data issue than the design issue. You would need to change the way the data is entered into the cube with the different measurement assigned to the unit.
    on a second thought(I understand that you dont have a luxury to change the cube design),  when you say you can see diff measurement type assigned to one unit in the masterdata, you can make the unit attribute as a navigational attribute in both the IO and cube. And just map measurent type in the update rules and derive the units from the masterdata table in the report.... does it make sense?
    Message was edited by:
            voodi

  • Many-to-One relationship with composed key

    Hi all,
    I have problems inserting an entity with a 1:n-relationship.
    The relationship is defined over two columns. In detail:
    There are two database-tables:
    VERDECK
    ID_PROJECT  NUMBER (key)
    ID_INTERN   VARCHAR2(10 BYTE) (key)
    UZSB
    ID_PROJECT          NUMBER (key)
    ID_UZSB             VARCHAR2(10 BYTE) (key)
    ID_PROJECT_VERDECK  NUMBER
    ID_INTERN_VERDECK   VARCHAR2(10 BYTE)
    On UZSB there is a referential integrity defined between these tables:
    FOREIGN KEY (ID_PROJECT_VERDECK, ID_INTERN_VERDECK)
    REFERENCES R57SCHRAUB.VERDECK (ID_PROJECT,ID_INTERN))
    This is mapped into JPA as follows:
    @Entity
    public class Verdeck implements Serializable {
         @EmbeddedId
         private VerdeckPK pk;
         @OneToMany(cascade={CascadeType.ALL},mappedBy="verdeck")
         private Collection<Uzsb> uzsbCollection;
    @Embeddable
    public class VerdeckPK implements Serializable {
         @Column(name="ID_PROJECT")
         private BigDecimal idProject;
         @Column(name="ID_INTERN")
         private String idIntern;
    @Entity
    public class Uzsb implements Serializable {
         @EmbeddedId
         private UzsbPK pk;
         @ManyToOne
              @JoinColumns({@JoinColumn(name="ID_PROJECT_VERDECK", referencedColumnName="ID_PROJECT"),@JoinColumn(name="ID_INTERN_VERDECK", referencedColumnName="ID_INTERN")})
         private Verdeck verdeck;
    @Embeddable
    public class UzsbPK implements Serializable {
         @Column(name="ID_UZSB")
         private String idUzsb;
         @Column(name="ID_PROJECT")
         private BigDecimal idProject;
    I try inserting a new entity VERDECK with some associated UZSBs as follows:
    Verdeck einVerdeck = new Verdeck();
    VerdeckPK myKey = new VerdeckPK();
    myKey.setIdProject(idProject);
    myKey.setIdIntern(lsId);
    einVerdeck.setPk(myKey);
    Uzsb lsUzsb = new Uzsb();
    UzsbPK lsUzsbKey = new UzsbPK();
    lsUzsbKey.setIdProject(idProject);
    lsUzsbKey.setIdUzsb(lsId);
    lsUzsb.setPk(lsUzsbKey);
    lsUzsb.setVerdeck(einVerdeck);
    Vector<Uzsb> uzsbColl = new Vector<Uzsb>();
    uzsbColl.add(lsUzsb);
    einVerdeck.setUzsbCollection(uzsbColl);
    em.persist(einVerdeck);
    As result I get the error
    "ORA-02291: integrity constraint (R57SCHRAUB.SYS_C0022330) violated - parent key not found"
    Does anybody have an idea? I think the problem could be the embedded key in Verdeck.
    Perhaps I should take this into account in my JPA-definition of the relationship?
    But how can I do this?
    Regards,
    Christoph

    Hi Christoph,
    our JPA implementation does not sort sqlstatements in the right order to work with foreign keys. This feature will come with the next release. The problem here is that databases check the constraint for every statement executed instead of checking at commit time (when our state is ok again).
    As workaround you can set the settings for the foreign key constraints to deferred (pls. see oracle docu: alter table defferrable / alter session deffered) and the database will check at commit time. Second approach would be to delete the foreign key constraints.
    hth
    -Andreas

  • EJB3: One-to-one relationships and auto-generation of primary key values...

    Dear Forum,
    I'm relatively new to JEE, and while I've so far enjoyed the convenience of EJB3 for most things, it seems that I have a corner case that can not be handled by the entity manager.
    First, here's a quick mockup of my entities:
        Gallery
                |
                -- [1] -------[1] ----> Author
                |
                -- [1] -------[M] ---> Photo
                                                  |
                                                  -- [1] ------ [1] -> PhotoImage
                                                                                     |
                                                                                     -- [1] ------ [1] -> IPTCData
                                                                                     |
                                                                                     -- [1] ------ [1] -> EXIFDataI also have a remote, stateless session bean that does nothing more than persist()/merge()/remove() and locate (through find() and a few custom queries) my Gallery and Photo instances.
    Now, the abridged version of my problem is this: when I persist a Photo, it naturally gets its primary key generated (I used @Id and @GeneratedValue). However, for some reason none of the other dependent entities inherit Photo's primary key value. In my client, I create a new Gallery locally and then persist it. I then create new Photo, PhotoImage, IPTCData and EXIFData instances. I add the IPTCData and EXIFData instances to PhotoImage (there are PhotoImage methods for adding those); then I add the PhotoImage instance to Photo (again, Photo has a setter for adding a PhotoImage). Then, I persist the Photo.
    --- Aside: ------------
    I've set up my relationships using annotations like @OneToMany (Gallery references a Collection of Photos), and @OneToOne (Photo's primary key references PhotoImage's primary key; PhotoImage's primary key references the primary keys of IPTCData and EXIFData). I've also added @JoinColumn annotations where necessary.
    Finally, I get the Gallery instance's Photo collection (public Collection<Photo> getPhotos()), I add the Photo to the collection, and I add the Photo collection BACK to the Gallery (public void setPhotos(Collection<Photo>)).
    At this point, the Gallery should have all of my entities contained inside of itself. However, when I persist the Gallery at this point, all of the entities show up in the database, but none of the primary keys get inherited. Photo's primary key gets generated automatically, of course, but the rest have zero (0) as their PK values. I had wanted, for example, IPTCData to get the value of Photo.id.
    I had assumed that the entity manager would persist everything for me provided that I told it, through my annotations, about which entities relate to which. Does persistence only work in the direction of retrieval? That is, does the entity manager only do its thing when fetching (versus setting) data when there is more than 1 object in the graph? I can't believe that it can't, otherwise we'd all be ditching it and going back to straight SQL to do our work.
    Thus, I HAVE to be doing something wrong, or else omitting to do something right.
    I've made other incarnations of the above setup, and none of them have worked perfectly. I've even set up foreign key constraints in the database, but I had my share of unresolvable problems there, too.
    So I guess my big question with all of this is: when you have a deeply nested graph of objects, can the entity manager figure everything out and persist all of the objects correctly and with the right values? If not, boo. If so, how does one accomplish this?
    I know that I could persist each and every entity separately in my client code, but I wanted to have a natural-looking way of piecing all of my entities together. More specifically, I could persist IPTCData explicitly; however, I want to be able to add everything to a Photo and only persist the Photo itself, with the idea that all of the objects and sub-objects would be persisted automagically.
    Is this possible? Or have I bought into a pipe dream with the guarantee of the proverbial magic bullet?
    Thanks to everyone in advance for his/her input.
    Regards,
    Michael

    Daniel,
    Late last night I found the solution to my problem. And you're right, it had everything to do with which side is wired to which. I got confused about which side to consider the "owning" side, since one can look at it from the perspective of the database or the application.
    Interestingly, the first 2 lines of your example code match my client code almost verbatim: First, I create a new Gallery (or else I get an existing one). I then create a new Photo and then add it to the Gallery's collection using add(). I then persist the Gallery. My session bean internally calls EntityManager.merge(gallery). How it differs from your example, though, is in the fact that, on an application level, a Photo has no knowledge whatsoever of a Gallery. Which is to say that my Photo class does not have a 'getGallery()' method. Somehow, Hibernate is able to figure it all out and still update Photo's 'parentIdRef' column in the database. My logs show that Hibernate issues a SQL UPDATE on the Photo after both a Gallery and a Photo have been created. It sets the Photo's 'parentIdRef' column to the primary key value of the owning Gallery.
    Getting back to the matter, my problem was not with being able to map a Photo to a Gallery; rather, I was unable to add a PhotoImage to a Photo and have the relationship get correctly mapped in the database. The relationship between a Photo and a Gallery is many-to-one: there can be many Photo objects inside of a Gallery. In the database, a Photo row contains a 'parentIdRef' column whose value is that of a Gallery's primary key. I used @OneToMany on the Gallery, since a Gallery is, from an application perspective, the "owning" side, even though it's only the Photo that knows who it's referring to since only IT contains the 'parentIdRef' column in the database.
    I tried setting up the relationship between a PhotoImage and a Photo in the same manner, with the PhotoImage having a 'parentIdRef' column and referring to a Photo's primary key. I had annotated the Photo's getPhotoImage() method with @OneToOne, along with an appropriate @JoinColumn.
    It was THIS part that I had backwards. With a @OneToMany relationship, the child refers back to the parent --- it can be no other way. However, with a @OneToOne relationship, the owner refers to the child.
    So, to make a long story short, all I had to do was create extra database columns for Photo. Those columns refer to the primary keys of PhotoImage, EXIFData and IPTCData. Concretely, for example, Photo.photoImageIdRef references PhotoImage.id. And so on and so forth.
    The only negative side-effect of this is that my database-level foreign key constraints are now broken, since Hibernate wants to persist PhotoImage, EXIFData and IPTCData before it persists Photo.
    I have to investigate more deeply the 'cascade=...' option of the @OneToOne annotation in order to find out it relates, if at all, to a database-level cascade.
    Anyway, thanks for the reply. It seems that you had a very good idea about what my problem was. I would have posted the fact that I had resolved the problem last night, except that it was too late and I was heading to bed. If you still want the Duke points, let me know. I don't currently know the rules about if, when and to whom I should issue points in cases like these when I've already solved the problem.
    Regards,
    Michael

  • Many-to-one synchronization

    I'm using DataServices to manage hiberate objects.  I have a simple many-to-one relationship between Account and Transaction (an account has many transactions).  I have two DataGrids in my application, one display accounts and their balances(which are derived from the trasactions, there is no balance field) the other displays transactions.  When I edit the accounts, the changes are propogated to the child transactions.  However, when I edit the transactions, the changes are not propagated to the accounts automatically.  If I edit the account or resort the columns it will update the balance.  My data-management-config.xml is below.  My question is, is there a way to make this work or is this not working by design?  I want my Account objects to automatically get the new Transactions associated with them so the balance will update correctly.
    <destination id="AccountHibernate">
         <adapter ref="java-dao" />
         <properties>
              <use-transactions>true</use-transactions>
              <source>flex.data.assemblers.HibernateAssembler</source>
              <scope>application</scope>
              <metadata>
                   <identity property="accountId"/>
                   <one-to-many property="transactions" destination="TransactionHibernate" lazy="false" read-only="true" load-on-demand="true"/>  
              </metadata>
              <network>
                   <session-timeout>0</session-timeout>
              </network>
              <server>
                   <hibernate-entity>budget.data.Account</hibernate-entity>
                   <fill-method>
                        <name>fill</name>
                        <params>java.util.List</params>
                   </fill-method>
                   <fill-configuration>
                        <use-query-cache>false</use-query-cache>
                        <allow-hql-queries>true</allow-hql-queries>
                   </fill-configuration>
              </server>
         </properties>
    </destination>
    <destination id="TransactionHibernate">
              <adapter ref="java-dao" />
              <properties>
                   <use-transactions>true</use-transactions>
                   <source>flex.data.assemblers.HibernateAssembler</source>
                   <scope>application</scope>
                   <metadata>
                        <identity property="transactionId"/>
                        <many-to-one property="account"  destination="AccountHibernate" lazy="false" />
                   </metadata>
              <network>
                   <session-timeout>0</session-timeout>
              </network>
              <server>
                   <hibernate-entity>budget.data.Transaction</hibernate-entity>
                   <fill-method>
                        <name>fill</name>
                        <params>java.util.List</params>
                   </fill-method>
                   <fill-configuration>
                        <use-query-cache>false</use-query-cache>
                        <allow-hql-queries>true</allow-hql-queries>
                   </fill-configuration>
              </server>
         </properties>
    </destination>

    Ed: Thanks for your response, I think I have a better idea of what is going
    on now.
    Regarding the first question: In this case I am just modifying an attribute,
    the relationship between them remains the same.
    I verified that adding a transaction does not update the size of the
    transaction collection the account has if I add the new transaction to the
    transactions collection.  However, if I add the transaction to the
    appropriate accounts list of transactions it does update the collection
    (i.e. there is one more element) but it does not update the balance.  I have
    since changed my balance to a property that is calculated by a query server
    side.  I noticed that even if I change a property on the account, it will
    not update the balance unless I call fill again.
    So I have two questions: 1) is there a way to make the account realize it
    has transactions added to it without adding them directly to the account's
    transaction collection?  2) Is there a way to force the account object to
    refresh the balance (i.e. re-run the query to generate it?).  I realize I
    can call fill() again client side and easily fix this, but I would like to
    do this in a way that causes all clients to have their account balances
    refreshed when the should i.e. I want the server to automatically push the
    new balance property.  If it matters I'm using HibernateAssembler.  Could I
    extend that to achieve this?
    Jim

  • I have had TOPLINK-28018  error afte I had added one-to-many or many-to-one

    Hello.
    I am using TopLink and Spring. I have the followng persistence.xml:
    <persistence xmlns="http://java.sun.com/xml/ns/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">
    <persistence-unit name="registry" transaction-type="RESOURCE_LOCAL">
    <mapping-file>ru/lanit/ps/registry/model/rpaymenttype.xml</mapping-file>
    <mapping-file>ru/lanit/ps/registry/model/radministrativelevel.xml</mapping-file>
    <mapping-file>ru/lanit/ps/registry/model/rterritory.xml</mapping-file>
    <mapping-file>ru/lanit/ps/registry/model/stateowner.xml</mapping-file>
    <properties>
    <property name="com.intellij.javaee.persistence.datasource" value="Datasource"/>
    <property name="toplink.logging.level" value="FINE"/>
    <property name="toplink.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
    <property name="toplink.jdbc.url" value="jdbc:hsqldb:mem:PUBSER"/>
    <property name="toplink.jdbc.password" value=""/>
    <property name="toplink.jdbc.user" value="sa"/>
    </properties>
    </persistence-unit>
    </persistence>
    All my classes are inherited from StateOwner.class and only the RTerritory class has "one-to-many" and "many-to-one" relationships. When I add rterritory.xml to persistence.xml I have the following error (before all works fine):
    log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
    log4j:WARN Please initialize the log4j system properly.
    [TopLink Config]: 2007.12.18 02:47:15.812--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.Long ru.lanit.ps.registry.model.StateOwner.getId()] is being defaulted to: ID.
    [TopLink Config]: 2007.12.18 02:47:15.859--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.Long ru.lanit.ps.registry.model.StateOwner.getStateTerritoryId()] is being defaulted to: STATETERRITORYID.
    [TopLink Config]: 2007.12.18 02:47:15.875--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.String ru.lanit.ps.registry.model.StateOwner.getStringId()] is being defaulted to: STRINGID.
    [TopLink Config]: 2007.12.18 02:47:15.875--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.String ru.lanit.ps.registry.model.StateOwner.getStateStatus()] is being defaulted to: STATESTATUS.
    [TopLink Config]: 2007.12.18 02:47:15.875--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.Long ru.lanit.ps.registry.model.StateOwner.getStateVersion()] is being defaulted to: STATEVERSION.
    [TopLink Config]: 2007.12.18 02:47:15.890--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.String ru.lanit.ps.registry.model.StateOwner.getStateAuthor()] is being defaulted to: STATEAUTHOR.
    [TopLink Config]: 2007.12.18 02:47:15.890--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.sql.Timestamp ru.lanit.ps.registry.model.StateOwner.getStateCreationDate()] is being defaulted to: STATECREATIONDATE.
    [TopLink Config]: 2007.12.18 02:47:15.890--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.sql.Timestamp ru.lanit.ps.registry.model.StateOwner.getStateModificationDate()] is being defaulted to: STATEMODIFICATIONDATE.
    [TopLink Config]: 2007.12.18 02:47:15.890--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.String ru.lanit.ps.registry.model.StateOwner.getStateComment()] is being defaulted to: STATECOMMENT.
    [TopLink Config]: 2007.12.18 02:47:15.906--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.sql.Timestamp ru.lanit.ps.registry.model.StateOwner.getStateProcessedDate()] is being defaulted to: STATEPROCESSEDDATE.
    [TopLink Config]: 2007.12.18 02:47:15.906--ServerSession(25709120)--Thread(Thread[main,5,main])--The discriminator column name for the root inheritance class [class ru.lanit.ps.registry.model.StateOwner] is being defaulted to: DTYPE.
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GroundOfRefusalServiceTarget' defined in class path resource [groundofrefusal.xml]: Cannot resolve reference to bean 'GroundOfRefusalDao' while setting bean property 'dao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GroundOfRefusalDao' defined in class path resource [groundofrefusal.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [openJPAsettings.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.lang.NullPointerException
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GroundOfRefusalDao' defined in class path resource [groundofrefusal.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [openJPAsettings.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.lang.NullPointerException
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [openJPAsettings.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.lang.NullPointerException
    Caused by: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.lang.NullPointerException
         at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:615)
         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:178)
         at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:218)
         at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
         at ru.lanit.ps.registry.VerifyApplicationContext.setUp(VerifyApplicationContext.java:44)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
         at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
         at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
         at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
         at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
         at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
         at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
         at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
         at com.intellij.rt.junit4.Junit4ClassSuite.run(Junit4ClassSuite.java:78)
         at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
    Caused by: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.lang.NullPointerException
         at oracle.toplink.essentials.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:212)
         ... 61 more
    Caused by: java.lang.NullPointerException
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.OneToManyAccessor.process(OneToManyAccessor.java:142)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:275)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.processRelationshipDescriptors(MetadataProject.java:564)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.process(MetadataProject.java:497)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:231)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:354)
         at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:584)
         ... 60 more
    Process finished with exit code -1
    This is my RTerritory.class and rterritory.xml
    public class RTerritory extends StateOwner {
    private static final long serialVersionUID = 5372570539234097349L;
    //link to parent
    private RTerritory parentTerritory;
    //title
    private String title;
    //string type
    private String type;
    //Level
    private Integer level;
    //set of children
    private Set<RTerritory> children = new HashSet<RTerritory>(0);
    public RTerritory() {
    public RTerritory(Long RTerritory, String title, String type) {
    setId(RTerritory);
    this.title = title;
    this.type = type;
    public RTerritory(Long id, RTerritory parentTerritory, String title, String type, Integer level) {
    super(id);
    this.parentTerritory = parentTerritory;
    this.title = title;
    this.type = type;
    this.level = level;
    public RTerritory(Long RTerritory, RTerritory parentTerritory, String title,
    String type, Set<RTerritory> RTerritories) {
    setId(RTerritory);
    this.parentTerritory = parentTerritory;
    this.title = title;
    this.type = type;
    this.children = RTerritories;
    public RTerritory(Long id, RTerritory parentTerritory, String title, String type, Integer level, Set<RTerritory> children) {
    super(id);
    this.parentTerritory = parentTerritory;
    this.title = title;
    this.type = type;
    this.level = level;
    this.children = children;
    public Integer getLevel() {
    return level;
    public void setLevel(Integer level) {
    this.level = level;
    public RTerritory getParentTerritory() {
    return this.parentTerritory;
    public void setParentTerritory(RTerritory parent_Territory) {
    this.parentTerritory = parent_Territory;
    public boolean hasParentTerritory() {
         return getParentTerritory() != null;
    public String getTitle() {
    return this.title;
    public void setTitle(String title) {
    this.title = title;
    public String getType() {
    return this.type;
    public void setType(String type) {
    this.type = type;
    public Set<RTerritory> getChildren() {
    return this.children;
    public void setChildren(Set<RTerritory> children) {
    this.children = children;
    public void addChildTerritory(RTerritory territory) throws Exception {
    if (children != null && territory != null) {
    children.add(territory);
    territory.setParentTerritory(this);
    } else {
    throw new Exception("Parameter is null or children is null");// TODO throw exception ?
    public void removeChildTerritory(RTerritory territory) {
    if (children != null && territory != null) {
    children.remove(territory);
    territory.setParentTerritory(null); // TODO territory.setParentTerritory(this.getParentTerritory()) ?
    public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    if (!super.equals(o)) return false;
    RTerritory that = (RTerritory) o;
    if (level != null ? !level.equals(that.level) : that.level != null) return false;
    if (title != null ? !title.equals(that.title) : that.title != null) return false;
    if (type != null ? !type.equals(that.type) : that.type != null) return false;
    return true;
    public int hashCode() {
    int result = super.hashCode();
    result = 31 * result + (title != null ? title.hashCode() : 0);
    result = 31 * result + (type != null ? type.hashCode() : 0);
    result = 31 * result + (level != null ? level.hashCode() : 0);
    return result;
         @Override
         public boolean isReference() {
              return true;
    <?xml version="1.0" encoding="UTF-8"?>
    <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
    version="1.0">
    <package>ru.lanit.ps.registry.model</package>
    <entity class="RTerritory" name="RTerritory">
    <table name="reg_r_territory"/>
    <primary-key-join-column name="R_TERRITORY" referenced-column-name="STATUS_ID"/>
    <attribute-override name="id">
    <column name="R_TERRITORY"/>
    </attribute-override>
    <attributes>
    <basic name="title">
    <column length="256" name="TITLE" nullable="false"/>
    </basic>
    <basic name="type">
    <column length="256" name="TYPE" nullable="false"/>
    </basic>
    <basic name="level">
    <column name="LEVEL"/>
    </basic>
    <!--<many-to-one name="parentTerritory" target-entity="RTerritory">
    <join-column name="PARENT_TERRITORY_ID"/>
    <cascade>
    <cascade-persist/>
    <cascade-merge/>
    <cascade-refresh/>
    </cascade>
    </many-to-one>-->
    <one-to-many name="children" mapped-by="parentTerritory" target-entity="RTerritory">
    <cascade>
    <cascade-all/>
    </cascade>
    </one-to-many>
    <transient name="parentTerritory"/>
    <!--<transient name="children"/>-->
    </attributes>
    </entity>
    </entity-mappings>
    If I make "parentTerritory" and "children" transient - all works well. Above workes also (comment out and without transient) on OpenJpa.
    What do I do wrong if I use TopLink?
    This is part of my applicationContext.xml
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceXmlLocation"
    value="/META-INF/persistence.xml"/>
    <property name="jpaVendorAdapter">
    <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter"/>
    </property>
    <property name="loadTimeWeaver">
    <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
    </property>
    </bean
    Thanks a lot.

    Hello.
    Thanks a lot for answer.
    When I comment out and remove transient I obtain the following exception:
    Internal Exception: java.util.NoSuchElementException
         at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:615)
         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:178)
         at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:218)
         at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
         at ru.lanit.ps.registry.VerifyApplicationContext.setUp(VerifyApplicationContext.java:44)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
         at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
         at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
         at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
         at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
         at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
         at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
         at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
         at com.intellij.rt.junit4.Junit4ClassSuite.run(Junit4ClassSuite.java:78)
         at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
    Caused by: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.util.NoSuchElementException
         at oracle.toplink.essentials.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:212)
         ... 61 more
    Caused by: java.util.NoSuchElementException
         at java.util.AbstractList$Itr.next(AbstractList.java:427)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor.getPrimaryKeyFieldName(MetadataDescriptor.java:539)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ObjectAccessor.processOneToOneForeignKeyRelationship(ObjectAccessor.java:113)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ObjectAccessor.processOwningMappingKeys(ObjectAccessor.java:190)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ManyToOneAccessor.process(ManyToOneAccessor.java:106)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:275)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor.getMappingForAttributeName(MetadataDescriptor.java:486)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.getOwningMapping(RelationshipAccessor.java:122)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.OneToManyAccessor.process(OneToManyAccessor.java:142)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:275)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.processRelationshipDescriptors(MetadataProject.java:564)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.process(MetadataProject.java:497)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:231)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:354)
         at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:584)
         ... 60 more
    Process finished with exit code -1
    I want to say that exception is same and I don't use GlassFish I run Unit test.
    This is my rterritory.xml now:
    <?xml version="1.0" encoding="UTF-8"?>
    <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
    version="1.0">
    <package>ru.lanit.ps.registry.model</package>
    <entity class="RTerritory" name="RTerritory">
    <table name="reg_r_territory"/>
    <primary-key-join-column name="R_TERRITORY" referenced-column-name="STATUS_ID"/>
    <attribute-override name="id">
    <column name="R_TERRITORY"/>
    </attribute-override>
    <attributes>
    <basic name="title">
    <column length="256" name="TITLE" nullable="false"/>
    </basic>
    <basic name="type">
    <column length="256" name="TYPE" nullable="false"/>
    </basic>
    <basic name="level">
    <column name="LEVEL"/>
    </basic>
    <many-to-one name="parentTerritory" target-entity="RTerritory">
    <join-column name="PARENT_TERRITORY_ID"/>
    <cascade>
    <cascade-persist/>
    <cascade-merge/>
    <cascade-refresh/>
    </cascade>
    </many-to-one>
    <one-to-many name="children" mapped-by="parentTerritory" target-entity="RTerritory">
    <cascade>
    <cascade-all/>
    </cascade>
    </one-to-many>
    <!--<transient name="parentTerritory"/>
    <transient name="children"/>-->
    </attributes>
    </entity>
    </entity-mappings>
    I can't understand What do I do wrong when I include "one-to-many" and "many-to-one" mapping? I want to note it (above mapping) works rightly if I use OpenJpa and one works rightly with TopLink if I remove one-to-many and many-to-one and do them transient.
    Thanks a lot.
    Message was edited by:
    user610937
    Message was edited by:
    user610937

  • Many-to-One user mapping to backend systems - possible?

    My apologies if this simple question has been asked many times earlier - I couldn't find it if it is so.
    I understand I can use user-mapping in single signon to map user X in portal to user A in backend system (say SAP BI).
    Can I map users X, Y, Z..... to one backend user A?
    What alternative I have (to let a number of portal users run some BW reports on the backend system - for which we want to use only one BI user-id)?

    An easier more manageble way of doing this is to create a group and assign the group to a backend user. That will establish your many to one relationship.
    We perform this for our vendors currently as they would like to see a single shopping cart in SRM.
    Just be cautious on the manner in which you leverage your single user as you can experience several locked objects depending on how things are accessed. Another thing to consider is making the backend user a service user as this will also allow you to change the password mapping policies on the users as in many cases you will need to remap the users every N days depending on your systems security parameters.
    Hope this helps.

  • Select with One-to-Many and Many-to-One without repeating

    Hi
    I have a customer who needs a report two sides left and right, but allowing for One-to-Many and Many-to-One relationships in the one report.
    A little background:-
    This has do do with listings on land and buildings.
    One building can be built on a few pieces of land.
    Similarly, there can be several buildings on one piece of land.
    What is required is a listing of buildings on the left, land on the right, but without repeating the "single line entries" either left or right.
    For example Building1 is on Land1 and Land2, and Building2 and Building3 are built on Land3.
    We need:-
    Building1 Land1
    ________Land2
    Building2 Land3
    Building3______
    The ___ just used for spacing so you get the idea ;)
    Essentially - a "break by" on columns on the left and right.
    The Buildings and Land are in different tables, with a link table - one row for each link.
    Any ideas?
    Thanks
    Mike

    To jitu.jk - first, this is not in SQL*Plus - its a report in APEX - second, I see no way to break on the left and the right in the same select.
    Maybe there is a way.
    To Etbin
    This is a very inovative solution - I've tried it out and the result is:-
    BUILDING LAND
    _____Land 4
    _____Land 3
    _____Land 5
    Building 2 Land 4
    Building 3 Land 1
    _____Land 4
    Building 4 Land 4
    Building 5 Land 3
    _____Land 4
    (The underscores I put in for spacing - not perfect but you get the idea - hard whe you write the reply in a fixed space font and it's displayed in the forum in variable space font!! ;)
    9 rows selected.
    This is not quite the desired result - in your list of associations, we have Building1 associated with Land 3,4, and 5.
    So for Building 1 we should have:-
    Building 1 Land 3
    ________Land 4
    ________Land 5..........
    But your result doesn't include Building 1 at all.
    The other requirement is that no building or land is ever repeated - so I came up with the concept of "groups".
    Starting with one building - I find all pieces of land that are associated - listing them on the right (without repeating the building.
    I then find any other buildings asociated with any of the land records that the first building was associated with.
    These are listed on the left - without repeating the land records on the right.
    This group is given a unique identifier of the minimum association ID (my associations have ID's).
    This all done, I use the unique ID as a break column ans summarise additional columns (area, value etc) below each group.
    Because of the summaries - adding area and value etc, I can't have any building or land duplicated as I would then "double count" the area, value etc.
    Maybe you method can be made to work with some tweaking.
    Very clever indeed - forums need great answers like this - it keeps us going.
    Thanks again
    Mike

  • SSAS - Many to Many Relationship Grain Filters Out Data (Many to One)

    I have a simple Many to One example: One Fact Table record has many Dimensional Items.  The Example I'm using is One FactEvent record can have multiple EventMembers.  These members are always unique so the relationship is really many to one (vs.
    many to many). The grain of the Fact is one row for every event.  Not all events have members, but I have stubbed those with -1
    I tried using a Referenced dimensional relationship, but it threw my total counts off.  I decided to make it more complicated by using a
    Many to Many relationship, but I had issues once I started slicing the data.
    The following are my two very simple tables:
    FactEvents:
    EventMemberID MemberKey EventMemberKey MemberName MemberGender
    1             1         -1             None       N          
    2             2         E2             Tyler      M          
    3             3         E2             John       M          
    4             4         E2             Sue        F          
    5             5         E5             Tim        M          
    6             6         E5             Jane       F          
    7             7         E12            Ashley     F          
    8             8         E12            Jessica    F          
    9             9         E12            Kristy     F          
    10            10        E17            Mike       M          
    11            11        E17            Josh       M          
    12            12        E18            Warren     M          
    13            13        E18            Eric       M           
    Here is the bridge Table:
    EventID EventBK EventName         EventMemberKey EventCount
    1       E1      Hockey Game       -1             1          
    2       E2      Soccer Game       E2             1          
    3       E3      Baseball Game     -1             1          
    4       E4      Concert           -1             1        
    5       E5      Food Festival     E5             1          
    6       E6      Movie Night       -1             1          
    7       E7      Data Group Event  -1             1          
    8       E8      City Tour         -1             1          
    9       E9      Ski Trip          -1             1        
    10      E10     Camping Trip      -1             1          
    11      E11     Hiking Trip       -1             1          
    12      E12     Community Cleanup E12            1          
    13      E13     Block Party       -1             1          
    14      E14     Toastmasters      -1             1          
    15      E15     Train Spotting    -1             1          
    16      E16     Plane Spotting    -1             1          
    17      E17     Fishing Trip      E17            1          
    18      E18     Hunting Trip      E18            1          
    19      E19     Street Hockey     -1             1          
    20      E20     Bonspiel          -1             1          
    You can see many events have no members and some events have multiple members.  There is not separate members Dim, just the bridge table.  I tried to build view that would work as bridge tables, but it started to feel like overkill.
    Here is the SSAS structure:
    Cube:
    I tried creating a bridge Dim and Measure Group that can be used to join FactEvents with DimMemberEvent:
    When I query the database tables directly, I can get the structure I'm looking for:
    Gender  Count
    F            5
    M           7
    N           15
    This represents that although there are 20 events, there were 5 Female and 7 Male participants and 15 events with No participants.  When looking at the cube in excel I get:
    Gender  Count
    F            3
    M           4
    N           15
    Grand Total 20
    The grand total is correct, however, it looks like it is grouping the events, so if there are multiple Female members at a particular event, they get rolled up.  You can see this better if I pull in member name:
    It includes all the names with count 1 ie. 5 Females with count 1, but the gender subtotal is 3 (as it is grouping the gender dimension)
    The detail member counts are good, but the rolled up M and F counts are stripping out duplicates.  Is there a way to model this in SSAS to preserve the detail member counts when the member dimension is used?  Is a many to many the best solution?
    This is all using SQL Server 2012 Multi-Dimensional Model. Thanks.

    Ok, for starters, if it's a one to many relationship, don't set it up as a many to many!  Avoid many to many relationships and really anything other than "regular" relationships. 
    Second, the tables you pasted the data for aren't the tables you are describing them as, based on the dsv screenshot you included.  If your post is confusing to the people who are wanting to help you, they will quickly move on.
    It seems that you are not clear on how to construct a star schema.  I will lay one out for you and hopefully this can help you on your journey.
    fact_member_event:
    event_id
    member_id
    member_event_count
    dim_member:
    member_id
    member_key
    member_name
    member_gender
    dim_event:
    event_id
    event_name
    fact_event:
    event_id
    event_count
    Or alternately, you could drop the fact_event fact table and have a calculated member that uses dimEvent.event.event.allmembers.count.  It's a little bit of a weird situation that I would want to play with, but I would start with the above.  
    Also if you post back and show query results, you should make it clear what columns  you are displaying.  I see "count" in your query above, but nowhere in the star schema do I see "member count"
    as a field.. I guess that's event count?
    Hope this helps,
    Ken

  • Many to Many Relationship using junction table..

    Hello im testing a many to many relation ship on j2ee and found this issue.
    Creating a relation ship table until now without succes to update the relationship table:
    code fragment as is:
    On application flow my session bean call the following method according with the specification i have no reason to call persist in my writer just on parent Object: Any clue on what is wrong ?
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void saveWriter (Book book , Writer writer){
    try {
    Book atBook = entityManager.merge(book);
    Writer atWriter = entityManager.merge(writer);
    book.getWriters().add(atWriter);
    entityManager.persist(atBook);
    entityManager.flush();
    }catch (Exception ex)
    ex.printStackTrace();
    <entity class="com.octech.biblio.domain.Book" name="book">
    <description></description>
    <table name="books" />
    <attributes>
    <id name="id">
    <generated-value strategy="IDENTITY"/>
    </id>
    <basic fetch="EAGER" name="bookName">
    <column insertable="true" length="128" name="bookname" table="" updatable="true"/>
    </basic>
    <many-to-one name="Library" fetch="LAZY" target-entity="com.octech.biblio.domain.Library">
    <join-table name="library_books">
    <join-column name="books_id"/>
    <inverse-join-column name="library_id"/>
    </join-table>
    <cascade/>
    </many-to-one>
    <many-to-many name="Writers" fetch="LAZY" target-entity="com.octech.biblio.domain.Writer">
    <join-table name="writers_books">
    <join-column name="books_id"/>
    <inverse-join-column name="writer_id"/>
    </join-table>
    <cascade/>
    </many-to-many>
    </attributes>
    </entity>
    <entity class="com.octech.biblio.domain.Writer" name="writer">
    <description></description>
    <table name="writers" />
    <attributes>
    <id name="id">
    <generated-value strategy="IDENTITY"/>
    </id>
    <basic fetch="EAGER" name="writerName">
    <column insertable="true" length="128" name="writer_name" table="" updatable="true"/>
    </basic>
    <many-to-many name="Books" fetch="LAZY" target-entity="com.octech.biblio.domain.Book">
    <join-table name="writers_books">
    <join-column name="writer_id"/>
    <inverse-join-column name="books_id"/>
    </join-table>
    <cascade/>
    </many-to-many>
    </attributes>
    </entity>

    sybrand_b wrote:
    The way you write it yes, but there is one minor detail.
    You can have a 0,1 or many relationship: one employee has zero, one or many phone numbers
    but you can not have the opposite, as it doesn't make sense.
    0, 1 or many phone numbers belong to 1 employee.
    It is customary to use 0,1 or m when the relationship is optional.
    Sybrand Bakker
    Senior Oracle DBAIs this correct now ?
    one to many : one employee has 0,1 or multiple phone numbers
    many to one : 1 or multiple phone numbers to one employee

  • How many Ipods can you use with one Itunes account?

    How many iPods can you use/sync with one iTunes account?

    PT wrote:
    Macistotle wrote:
    Unless you have DRM still haunting your tunes ... Then you can only use those songs on 5 devices. Otherwise, connect as many as you like (as stated above).
    No, you can sync your DRM tracks to an unlimited number of iPods (but only authorized to play on 5 different computers/user accounts)
    Patrick
    So I can sync two iPods to my iTunes account and sync the same digital copy movies that come with some o' my DVDs to both ipods? Do movies make a difference really, DRM-Wise? Thanks in advance.

Maybe you are looking for

  • Slow logon for roaming profiles on Server 2012 R2.

    Hey all, We have migrated Windows Server 2008 R2 to 2012 R2. After this, roaming profiles began to take 7-8 mins to 15-16 mins to logon to the 2012 R2 RDHS. Same roaming profiles have no problems logging on other RDS servers running Server 2008 R2. A

  • Is there a way to split clips in the Event browser? (audio-synch related)

    It seems there is no way to split an event-clip (a clip that appears in the Event browser). You can split Events--but only if they consist of more than one clip. And then you can only split them between two clips. People who have transferred analog v

  • Soap Adapter - XI_J2EE_ADAPTER_XI_HANDLER Error

    Hello, we have a very informative error here for SOAP outbound adapter: Sending to the SOAP-Adapter address  ..../SOAP_Adapter/MessageServlet.... with the test tool in RWB we have this error: Error category: XI_J2EE_ADAPTER_XI_HANDLER Error code: GEN

  • Oracle Application Server 10.1.3.1

    Hi all, I'm trying to install Oracle Application Server on Red Hat Enterprise Linux 5, when I launch the "runInstaller" script, I get a message saying that Red Hat Linux is supporter only till version 4. Is there any version of OAS that supports RHEL

  • Unable to access url outside the machine

    Hi All, when i m trying to runing my web Object project (WO 5.4) the URL bing generated is :- http://127.0.0.1:4002/cgi-bin/WebObjects/Test.woa The web Object is not generating the URL consisting of System IP (Eg 192.168.3.103) Due to which I am unab