One-to-Many CMR problem
I am trying to get Container Managed Relationships working with Oracle Application Server. I am sure that the problem it quite obvious to anyone who has got this working before, but after carefully following numerous examples, I still cant get them to work. I have various issues including the application server blocking when it calls the getB() method in "A" to populate the items from table "B", even though the generated SQL looks okay e.g., "select B_PK from B where (b_fk = 1)".
I would be extremely grateful if you could point out my (hopefully obvious) mistake as I wrestled with it for the past couple of weeks.
Any ideas?
Cheers,
Jonathan
I have two tables A and B; A has a one-to-many relationship with B:
Table A:
A_PK (primary key)
A_NAME
Table B:
B_PK (primary key)
B_NAME
B_FK (foreign key to table A)
My ejb-jar.xml file is:
<ejb-jar>
<enterprise-beans>
<entity>
<description>Entity Bean ( CMP )</description>
<display-name>A</display-name>
<ejb-name>A</ejb-name>
<home>mypackage1.AHome</home>
<remote>mypackage1.A</remote>
<local-home>mypackage1.ALocalHome</local-home>
<local>mypackage1.ALocal</local>
<ejb-class>mypackage1.impl.ABean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Long</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>A</abstract-schema-name>
<cmp-field><field-name>a_pk</field-name></cmp-field>
<cmp-field><field-name>a_name</field-name></cmp-field>
<primkey-field>a_pk</primkey-field>
</entity>
<entity>
<description>Entity Bean ( CMP )</description>
<display-name>B</display-name>
<ejb-name>B</ejb-name>
<home>mypackage1.BHome</home>
<remote>mypackage1.B</remote>
<local-home>mypackage1.BLocalHome</local-home>
<local>mypackage1.BLocal</local>
<ejb-class>mypackage1.impl.BBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Long</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>B</abstract-schema-name>
<cmp-field><field-name>b_pk</field-name></cmp-field>
<cmp-field><field-name>b_name</field-name></cmp-field>
<cmp-field><field-name>b_fk</field-name></cmp-field>
<primkey-field>b_pk</primkey-field>
</entity>
</enterprise-beans>
<relationships>
<ejb-relation>
<ejb-relation-name>A-B</ejb-relation-name>
<ejb-relationship-role>
<multiplicity>One</multiplicity>
<cascade-delete/>
<relationship-role-source>
<ejb-name>A</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>b</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>B</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
</relationships>
</ejb-jar>
And my orion-ejb-jar.xml file is:
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
<orion-ejb-jar>
<enterprise-beans>
<entity-deployment name="A" copy-by-value="false" data-source="jdbc/Connection1DS" exclusive-write-access="false" table="a">
<primkey-mapping>
<cmp-field-mapping name="a_pk" persistence-name="a_pk"
persistence-type="int(11)"/>
</primkey-mapping>
<cmp-field-mapping name="a_pk" persistence-name="a_pk"
persistence-type="int(11)"/>
<cmp-field-mapping name="a_name" persistence-name="a_name"
persistence-type="varchar(100)"/>
<cmp-field-mapping name="b">
<collection-mapping table="B">
<primkey-mapping>
<cmp-field-mapping name="b_fk" persistence-name="B_FK"/>
</primkey-mapping>
<value-mapping type="mypackage1.BLocal">
<cmp-field-mapping>
<entity-ref home="B">
<cmp-field-mapping name="b_pk" persistence-name="B_PK"/>
</entity-ref>
</cmp-field-mapping>
</value-mapping>
</collection-mapping>
</cmp-field-mapping>
</entity-deployment>
<entity-deployment name="B" copy-by-value="false" data-source="jdbc/Connection1DS" exclusive-write-access="false" table="b">
<primkey-mapping>
<cmp-field-mapping name="b_pk" persistence-name="b_pk"
persistence-type="int(11)"/>
</primkey-mapping>
<cmp-field-mapping name="b_pk"
persistence-name="b_pk" persistence-type="int(11)"/>
<cmp-field-mapping name="b_fk" persistence-name="b_fk"
persistence-type="int(11)"/>
</entity-deployment>
</enterprise-beans>
<assembly-descriptor>
<default-method-access>
<security-role-mapping impliesAll="true" name="<default-ejb-caller-role>"/>
</default-method-access>
</assembly-descriptor>
</orion-ejb-jar>
Ok, I found out something strange. If I do the addPet operation twice in the client the new relationship is created, too.
p = home.create("Violetta");
p.addNewPet("Jenny");
p = home.create("Frank");
p.addPet("Jenny");
p.addPet("Jenny");
May this be a timing problem? Or is there a command I could execute to ensure all data manipulation is populated to the DB. (Like close() in JDBC)
TIA
Frank
Similar Messages
-
Hi,
I am haviing a crystal report problem. The problem relates to a one-to-many relationship involving two tables.
I have a similar setup to the following:
I have 2 database tables: table1 & table2
table1 consists of 3 fields:
{id#}, {yes/no},{up/down}
table2 consists of 2 fields:
{id#},
the field can contain any of the following values: 'open', 'closed', 'final', 'complete'.
The problem is that there exist many states to one id#.
I have a bar graph in my report that displays a bar for the count of the{yes/no} field and a bar for the count of the {up/down} field. I want also a bar for the count of when the field = 'final'.
What happens when I write a formula for the field in the second table and place it in the 'show values' section of the chart expert, is the count displayed in each bar on the graph increases significantly. I am assuming this is because there are multiple records in table 2 for each record in table 1.
What I want to happen is that the graph displays bar 1 and bar 2 correctly and then when I put in the formula for the third bar, it simply displays that bar with the count for when the field = 'final'. I dont want it to affect the whole garph.
Has anyone got any suggestions on how I can do this?
I have tried messing around with the distinct records setting in crystal and also by writing an sql query specifying DISTINCT keyword instead of using the select expert, but to no avail.
Please please can someone help me with this issue.
Thank you.
JYou can add a 1-1 query key through the code API in a descriptor amendment method. You could also define a selection criteria on the 1-m mapping to filter the type=2.
Example: (see Foundation Library manual 8-17)
OneToOneQueryKey queryKey = new OneToOneQueryKey();
queryKey.setName("organization");
queryKey.setReferenceClass(Organization.class);
ExpressionBuilder builder = new ExpressionBuilder();
queryKey.setJoinCriteria(builder.getField("ORGANIZATION.ORG_ID").equal(builder.getParameter("RELATIONSHIP.PARENT_ID").and(builder.getParamater("RELATIONSHIP.RELATIONSHIP_TYPE").equal(2)));
relationDescriptor.addQueryKey(queryKey);
Example: (of 1-m mapping with selection criteria)
OneToManyMapping mapping = new OneToManyMapping();
mapping.setReferenceClass(Relation.class);
mapping.setTargetForeignKey("RELATION.PARENT_ID");
ExpressionBuilder builder = new ExpressionBuilder();
mapping.setSelectionCriteria(builder.getField("RELATIONSHIP.PARENT_ID").equal(builder.getParameter("ORGANIZATION.ORG_ID").and(builder.getField("RELATIONSHIP.RELATIONSHIP_TYPE").equal(2)));
orgDescriptor.addMapping(mapping); -
Aggregate one-to-many relationship problem
Hello,
After migrating from Toplink 9i I've stumbled across a problem with our aggregate objects.
Toplink Workbench reports no errors and generates a nice XML but in runtime I get this error whenever a aggregate function is used.
[TopLink fin]: 2008.02.13 03:18:11.552--ServerSession(12626425)--Connection(29948747)--Thread(Thread[main,5,main])--SELECT DISTINCT t0.NPL_PACK_ID, t0.NPL_ID FROM NPL_MEDPROD t3, FASS_MEDPROD t2, NPL_MEDPROD t1, NPL_PACKAGE t0 WHERE (((t0.NPL_ID = t1._Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test) AND ((t1.NPL_ID = t2.NPL_ID) AND (t3.NPL_ID LIKE '19750613000031%'))) AND (t3.NPL_ID = t2.NPL_ID))
Caused by: Undantag [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)): oracle.toplink.exceptions.DatabaseException
Internt undantag: java.sql.SQLException: ORA-00911: invalid character
Felkod: 911
I belive that problem resides in this clause :
t1._Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test
I've created a small test project with just a couple of classes but the same aggregate problem occurs which has let me to believe the problem does not come from the migrating process which was my first guess. If anyone could help me discover what I am doing wrong it would be very appreciated. Below is my test project output.
<?xml version="1.0" encoding="UTF-8"?>
<toplink:object-persistence version="Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)" xmlns:opm="http://xmlns.oracle.com/ias/xsds/opm" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:toplink="http://xmlns.oracle.com/ias/xsds/toplink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<opm:name>test</opm:name>
<opm:class-mapping-descriptors>
<opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
<opm:class>se.lif.fass.fassdata.impl.FASSMedProdImpl</opm:class>
<opm:alias>FASSMedProdImpl</opm:alias>
<opm:primary-key>
<opm:field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
</opm:primary-key>
<opm:events xsi:type="toplink:event-policy"/>
<opm:querying xsi:type="toplink:query-policy"/>
<opm:attribute-mappings>
<opm:attribute-mapping xsi:type="toplink:one-to-one-mapping">
<opm:attribute-name>_Medprod</opm:attribute-name>
<opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl</opm:reference-class>
<opm:private-owned>true</opm:private-owned>
<opm:foreign-key>
<opm:field-reference>
<opm:source-field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
<opm:target-field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
</opm:field-reference>
</opm:foreign-key>
<opm:foreign-key-fields>
<opm:field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
</opm:foreign-key-fields>
<toplink:batch-reading>true</toplink:batch-reading>
<toplink:selection-query xsi:type="toplink:read-object-query"/>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>id</opm:attribute-name>
<opm:read-only>true</opm:read-only>
<opm:field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
</opm:attribute-mapping>
</opm:attribute-mappings>
<toplink:descriptor-type>independent</toplink:descriptor-type>
<toplink:instantiation/>
<toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
<toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
<toplink:tables>
<toplink:table name="FASS_MEDPROD"/>
</toplink:tables>
</opm:class-mapping-descriptor>
<opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
<opm:class>schemas_npl.instance.impl.MedprodTypeImpl</opm:class>
<opm:alias>MedprodTypeImpl</opm:alias>
<opm:primary-key>
<opm:field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
</opm:primary-key>
<opm:events xsi:type="toplink:event-policy"/>
<opm:querying xsi:type="toplink:query-policy"/>
<opm:attribute-mappings>
<opm:attribute-mapping xsi:type="toplink:aggregate-object-mapping">
<opm:attribute-name>_Medprodpack</opm:attribute-name>
<toplink:reference-class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl</toplink:reference-class>
<toplink:allow-null>false</toplink:allow-null>
<toplink:field-translations>
<toplink:field-translation>
<toplink:source-field name="_Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test" xsi:type="opm:column"/>
<toplink:target-field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
</toplink:field-translation>
</toplink:field-translations>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>_Nplid</opm:attribute-name>
<opm:field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>id</opm:attribute-name>
<opm:read-only>true</opm:read-only>
<opm:field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
</opm:attribute-mapping>
</opm:attribute-mappings>
<toplink:descriptor-type>independent</toplink:descriptor-type>
<toplink:instantiation/>
<toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
<toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
<toplink:tables>
<toplink:table name="NPL_MEDPROD"/>
</toplink:tables>
</opm:class-mapping-descriptor>
<opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
<opm:class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl</opm:class>
<opm:alias>MedprodTypeImpl$MedprodpackTypeImpl</opm:alias>
<opm:events xsi:type="toplink:event-policy"/>
<opm:querying xsi:type="toplink:query-policy"/>
<opm:attribute-mappings>
<opm:attribute-mapping xsi:type="toplink:one-to-many-mapping">
<opm:attribute-name>_Presentation</opm:attribute-name>
<opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:reference-class>
<opm:private-owned>true</opm:private-owned>
<opm:target-foreign-key>
<opm:field-reference>
<opm:source-field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
<opm:target-field name="_Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test" xsi:type="opm:column"/>
</opm:field-reference>
</opm:target-foreign-key>
<toplink:batch-reading>true</toplink:batch-reading>
<toplink:container xsi:type="toplink:list-container-policy">
<toplink:collection-type>com.sun.xml.bind.util.ListImpl</toplink:collection-type>
</toplink:container>
<toplink:selection-query xsi:type="toplink:read-all-query">
<toplink:container xsi:type="toplink:list-container-policy">
<toplink:collection-type>com.sun.xml.bind.util.ListImpl</toplink:collection-type>
</toplink:container>
</toplink:selection-query>
</opm:attribute-mapping>
</opm:attribute-mappings>
<toplink:descriptor-type>aggregate</toplink:descriptor-type>
<toplink:instantiation/>
<toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
<toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
</opm:class-mapping-descriptor>
<opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
<opm:class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:class>
<opm:alias>MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:alias>
<opm:primary-key>
<opm:field table="NPL_PACKAGE" name="NPL_PACK_ID" xsi:type="opm:column"/>
</opm:primary-key>
<opm:events xsi:type="toplink:event-policy"/>
<opm:querying xsi:type="toplink:query-policy"/>
<opm:attribute-mappings>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>_Nplpackid</opm:attribute-name>
<opm:field table="NPL_PACKAGE" name="NPL_PACK_ID" xsi:type="opm:column"/>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:one-to-one-mapping">
<opm:attribute-name>backref</opm:attribute-name>
<opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl</opm:reference-class>
<opm:foreign-key>
<opm:field-reference>
<opm:source-field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
<opm:target-field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
</opm:field-reference>
</opm:foreign-key>
<opm:foreign-key-fields>
<opm:field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
</opm:foreign-key-fields>
<toplink:indirection xsi:type="toplink:value-holder-indirection-policy"/>
<toplink:selection-query xsi:type="toplink:read-object-query"/>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>id</opm:attribute-name>
<opm:read-only>true</opm:read-only>
<opm:field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
</opm:attribute-mapping>
</opm:attribute-mappings>
<toplink:descriptor-type>independent</toplink:descriptor-type>
<toplink:instantiation/>
<toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
<toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
<toplink:tables>
<toplink:table name="NPL_PACKAGE"/>
</toplink:tables>
</opm:class-mapping-descriptor>
</opm:class-mapping-descriptors>
<toplink:login xsi:type="toplink:database-login">
<toplink:platform-class>oracle.toplink.platform.database.oracle.Oracle8Platform</toplink:platform-class>
<toplink:user-name>fassadmin</toplink:user-name>
<toplink:password>3CC3773C96563CA0C89634305615359CD62D1A19DF561D1E</toplink:password>
<toplink:driver-class>oracle.jdbc.driver.OracleDriver</toplink:driver-class>
<toplink:connection-url>jdbc:oracle:oci8:@DB2</toplink:connection-url>
</toplink:login>
</toplink:object-persistence>
Regards
/JonasThe issue is in the one-to-many mapping in the aggregate,
<br>
<opm:attribute-mapping xsi:type="toplink:one-to-many-mapping">
<opm:attribute-name>_Presentation</opm:attribute-name>
<opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:reference-class>
<opm:private-owned>true</opm:private-owned>
<opm:target-foreign-key>
<opm:field-reference>
<opm:source-field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
<opm:target-field name="_Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test" xsi:type="opm:column"/>
</opm:field-reference>
</opm:target-foreign-key>There is an issue with the Mapping Workbench and shared aggregates with one-to-many mappings and translating the foreign key fields. Did this work before, I would be surprized if it did, unless the 2.5 Builder was used?
Anyway the easiest workaround is to either edit the XML and change the NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test column name to what it should be, or define a descriptor amendment method to define the one-to-many mapping with the correct field names.
-- James : EclipseLink -
In my JPA project I'm using these three classes:
Cart.java:
package com.spinnaker.pedja;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.*;
@Entity(name = "Cart")
@Table(schema = "shop")
public class Cart {
@Id
@Column(name = "cart_id")
private int Cart_id;
@Column(name = "cart_date")
private Date date;
@OneToMany(mappedBy = "cartItemPK", targetEntity = CartItemPK.class)
private Set cartitemCollection = new HashSet(0);
@ManyToOne
@JoinColumn(name = "customer_id")
private Customer customer;
public Customer getCustomer() {
return customer;
public void setCustomer(Customer customer) {
this.customer = customer;
public Cart() {
public Set getCartitemCollection() {
return cartitemCollection;
public void setCartitemCollection(Set cartitemCollection) {
this.cartitemCollection = cartitemCollection;
public int getCart_id() {
return Cart_id;
public void setCart_id(int cart_id) {
this.Cart_id = cart_id;
public Date getDate() {
return date;
public void setDate(Date date) {
this.date = date;
}, CartItem.java:
package com.spinnaker.pedja;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@Table(schema = "shop")
public class CartItem implements Serializable {
@EmbeddedId
@ManyToOne
// @JoinColumn(name = "cart_id")
CartItemPK cartItemPK;
@Column(name = "quantity")
private int quantity;
@Column(name = "unit_price")
private double unit_price;
// @JoinColumn(name = "cart_id")
// private Cart cart;
// public Cart getCart() {
// return cart;
// public void setCart(Cart cart) {
// this.cart = cart;
public CartItem() {
public CartItemPK getCartItemPK() {
return cartItemPK;
public void setCartItemPK(CartItemPK cartItemPK) {
this.cartItemPK = cartItemPK;
public int getQuantity() {
return quantity;
public void setQuantity(int quantity) {
this.quantity = quantity;
public double getUnit_price() {
return unit_price;
public void setUnit_price(double unit_price) {
this.unit_price = unit_price;
}and CartItemPK.java:
package com.spinnaker.pedja;
import java.io.Serializable;
import javax.persistence.*;
@Table(schema="shop")
@Embeddable
public class CartItemPK implements Serializable{
@Column(name="item_id",nullable=false)
private int itemId;
// @ManyToOne
// @JoinColumn(name = "cart_id")
// private Cart cart;
@Column(name="cart_id",nullable=false)
private int cartId;
public int getItemId() {
return itemId;
public void setItemId(int itemId) {
this.itemId = itemId;
public int getCartId() {
return cartId;
public void setCartId(int cartId) {
this.cartId = cartId;
I'm having problem with mapping one to many relationship between Cart and CartItem.I had to introduce CartItemPK class because CartItem has composite primary key.Help please!!!In my test class I'm using this code:
Cart cart=em.find(Cart.class, 33);
Set cartItems=cart.getCartitemCollection();
for (Iterator iterator = cartItems.iterator(); iterator.hasNext();) {
CartItem cart_item = (CartItem) iterator.next();
System.out.println(cart_item.getCartItemPK().getCartId());
}and this error happens:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.spinnaker.pedja.Cart.cartitemCollection[com.spinnaker.pedja.CartItemPK]
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:247)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:159)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:95)
at com.spinnaker.pedja.test.Test.main(Test.java:30)
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.spinnaker.pedja.Cart.cartitemCollection[com.spinnaker.pedja.CartItemPK]
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:979)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:530)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:471)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1136)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1211)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:847)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:178)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:235)
... 4 more
I didn't find any example on the internet about my particular case.In the database,Cart and CartItem are conected via cart_id field.But in my JPA project,cart_id field is a part of a composite key CarItemPK. -
One-to-many relationship: problem with several tables on the one side...
Hello
I'm having problems developing a database for a content management system. Apart from details, I've got one main table, that holds the tree structure of the content ("resources") and several other tables that contain data of a particular datatype ("documents", "images", etc.). Now, there's one-to-many relationship between "resources" table and all the datatype tables - that is, in the "resources" table there's "resource_id" column, being a foreign key referenced to the "id" columns in the datatype tables.
The problem is that this design is deficient. I can't tell form the "resource_id" column from which datatype table to get the data. It seems to me that one-to-many relationship only works with two tables. If the data on the one side of the relationship is contained in several tables, problems arise.
Anybody knows a solution? I would be obliged.
Regards
HavocadoHi;
A simple way may be create a view on referenced tables:
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL>
SQL> drop table resources;
Table dropped
SQL> create table resources(id number, name varchar2(12));
Table created
SQL> insert into resources values(1,'Doc....');
1 row inserted
SQL> insert into resources values(2,'Img....');
1 row inserted
SQL> drop table documents;
Table dropped
SQL> create table documents(id number, resource_id number,type varchar2(12));
Table created
SQL> insert into documents values(1,1,'txt');
1 row inserted
SQL> drop table images;
Table dropped
SQL> create table images(id number, resource_id number,path varchar2(24));
Table created
SQL> insert into images values(1,2,'/data01/images/img01.jpg');
1 row inserted
SQL> create or replace view vw_resource_ref as
2 select id, resource_id, type, null as path from documents
3 union
4 select id, resource_id, null as type, path from images;
View created
SQL> select * from resources r inner join vw_resource_ref rv on r.id = rv.resource_id;
ID NAME ID RESOURCE_ID TYPE PATH
1 Doc.... 1 1 txt
2 Img.... 1 2 /data01/images/img01.jpg
SQL> Regards.... -
One-to-many relationships problem
Hi,
I'm having some problems with one-to-many relationships.
I've a two way relationship beetwen Person and Document.
Person has a collection of Documents (1-n).
Document has an instance for Person.
In my database schema Document has a FK for person.
The problem occurs when I'm trying to save the Person object
with a collection of Documents.
Oracle gives me the following message:
ORA-00001: unique constraint (SMS.PK_PERSON) violated
In my kodo.properties file I put:
kodo.jdbc.ForeignKeyConstraints: true
It seems that when the collection of Documents is persisted, kodo tries to
save a new Person object for each Document.
When I have just one instance of Document in my collection kodo persists
it ok, but when I have move instances I get
that problem.
Can somebody help me?
Thanks in advance,
Joan CaffeeYou need to make sure each Document references the same Person object in
the JVM. JDO persists your object model as-is. Each distinct JVM
object becomes a distinct database record. You can't have multiple JVM
objects in the same PersistenceManager representing the same database
record. -
Persistence and transactions: One-to-many consistency problem
Hi,
we have the following problem: We have two persistent classes A and B that are connected via a one-to-many (1:n) relationship. Now we
1. get an object "a" of class A and a number of related objects of class B from the persistence manager. Then we
3. delete the relationship between "a" and one object of class B. Then (without commit)
4. the GUI requests to show all related Bs for our given "a" and:
5. the query returns also the "deleted" object.
All these steps are performed within the same (object oriented) top level transaction.
The reason for this seems clear to us: The removal of the B has not been persisted in the DB. However, we don't really know how to deal with it...
Any suggestion is welcome.
ChristophHi Chris,
it is unclear to me if you are re-reading the database after you delete the 'b' item.
Anyway, the way persistent objects work is that changes are not written to the database until the SAP LUW ends with a COMMIT WORK.
Cheers
Graham Robbo -
Unidirectional one-to-many CMR in OC4J 9.0.3.1699
Hi,
I have the following issue with the new (productiv) OC4J 9.0.3 build 020927.1699, with did not occur with
build 020725.1695. I would like to deploy local entity beans CMRDepartment -1--n-> CMREmployee with container managed relations. Here's the relation part of ejb-jar.xml
<ejb-relation>
<ejb-relation-name>theEmployees2theDepartment</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>theEmployees</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>CMREmployee</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>theDepartment</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>CMRDepartment</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>theEmployees</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
Now the problem is that the depoyment generates an database table CMREmployee_cmrtest_cmrtest for CMR with a foreign key column CMRDepartment_theEmployees referencing the CMRDepartment_cmrtest_cmrtest table for the CMRDepartment bean, even though the relation is not navigable from Emp to Dept. Is this a bug or a feature? Here's the CMREmployee part of the orion-ejb-jar.xml after deployment:
<entity-deployment name="CMREmployee" location="CMREmployee" wrapper="CMREmployeeHome_EntityHomeWrapper27" local-wrapper="CMREmployeeLocalHome_EntityHomeWrapper16" table="CMREmployee_cmrtest_cmrtest" data-source="jdbc/OracleDS" exclusive-write-access="false" locking-mode="optimistic" update-changed-fields-only="true" delay-updates-until-commit="true" min-instances-per-pk="0" max-instances-per-pk="50" disable-wrapper-cache="true">
<primkey-mapping>
<cmp-field-mapping name="id" persistence-name="id" />
</primkey-mapping>
<cmp-field-mapping name="name" persistence-name="name" />
<cmp-field-mapping name="theAddress">
<entity-ref home="CMRAddress">
<cmp-field-mapping name="theAddress" persistence-name="theAddress" />
</entity-ref>
</cmp-field-mapping>
<cmp-field-mapping name="CMRDepartment_theEmployees">
<entity-ref home="CMRDepartment">
<cmp-field-mapping name="CMRDepartment_theEmployees" persistence-name="CMRDepartment_theEmployees" />
</entity-ref>
</cmp-field-mapping>
<cmp-field-mapping name="theProjects">
<collection-mapping table="CMRProject_CMREmployee__1ftrph">
<primkey-mapping>
<cmp-field-mapping name="CMREmployee_id">
<entity-ref home="CMREmployee">
<cmp-field-mapping name="CMREmployee_id" persistence-name="CMREmployee_id" />
</entity-ref>
</cmp-field-mapping>
</primkey-mapping>
<value-mapping type="cmrtest.CMRProjectLocal">
<cmp-field-mapping name="CMRProject_id">
<entity-ref home="CMRProject">
<cmp-field-mapping name="CMRProject_id" persistence-name="CMRProject_id" />
</entity-ref>
</cmp-field-mapping>
</value-mapping>
</collection-mapping>
</cmp-field-mapping>
<finder-method>
<!-- Generated SQL: "SELECT o.id FROM CMREmployee_cmrtest_cmrtest o -->
<method>
<ejb-name>CMREmployee</ejb-name>
<method-name>findAllInstances</method-name>
<method-params>
</method-params>
</method>
</finder-method>
<ejb-ref-mapping name="ejb/references/theAddress/CMRAddressLocal" />
<ejb-ref-mapping name="ejb/references/theProjects/CMRProjectLocal" />
<resource-ref-mapping name="jdbc/EJBDataSource" />
<resource-ref-mapping name="jms/EJBQueueConnectionFactory" />
<resource-ref-mapping name="jms/EJBTopicConnectionFactory" />
<resource-env-ref-mapping name="jms/EJBQueue" />
<resource-env-ref-mapping name="jms/EJBTopic" />
</entity-deployment>
Any hints would be very wellcome.
Regards
StefanTrond,
when ou deploy your application, you should not need to include the orion-ejb-jar.xml.
Also, if you have previously deployed the application, delete the application directory UNDER both applicatopn-deployments and applications. The directory will be your application's name.
Hope this helps,
Rob Cole
Oracle -
Hi.
I,m trying to combine two tables into one. Table 1 is persons. Table two is movies. Table to insert in is, lets say per_mov_table
I'm building a form that will get values from both tables 1 and 2 and insert into a new one.
In that form I can select a person from a dropdown list. And select movies from a select list. Its
possible to select multiple movies per person.
I,m trying with the ADDT behaviors. but I get some strange results.
Lets say I select person nr 2 and movies 2,3 and 4 in the form. Then I would expect results in new table to be something like: (id_fk_pers id_fk_mov are the foregin keys)
id_per_mov_table id_fk_pers id_fk_mov
1 2 2
2 2 3
3 2 4
instead the output is:
id_per_mov_table id_fk_pers id_fk_mov
1 2 1
2 77 2
3 77 3
4 77 4
First it inserts a new row with som bogus value that I dont know where it comes from
Then it seemes that the id_fk_pers have som sort of autoincrement because if I do the same insert again I get
id_per_mov_table id_fk_pers id_fk_mov
1 2 1
2 80 2
3 80 3
4 80 4
So id_fk_pers is not getting the person id from the persons table. it is linked together with pers_id and id_fk_pers.
So what am I to do? I'm desperate to get this working.
I dont care how to do it but the goal is to show a detail page with one person and many movies with a ?pers_id link from another page.
Regards
Olle
ps. sorry for the long postHi.
I,m trying to combine two tables into one. Table 1 is persons. Table two is movies. Table to insert in is, lets say per_mov_table
I'm building a form that will get values from both tables 1 and 2 and insert into a new one.
In that form I can select a person from a dropdown list. And select movies from a select list. Its
possible to select multiple movies per person.
I,m trying with the ADDT behaviors. but I get some strange results.
Lets say I select person nr 2 and movies 2,3 and 4 in the form. Then I would expect results in new table to be something like: (id_fk_pers id_fk_mov are the foregin keys)
id_per_mov_table id_fk_pers id_fk_mov
1 2 2
2 2 3
3 2 4
instead the output is:
id_per_mov_table id_fk_pers id_fk_mov
1 2 1
2 77 2
3 77 3
4 77 4
First it inserts a new row with som bogus value that I dont know where it comes from
Then it seemes that the id_fk_pers have som sort of autoincrement because if I do the same insert again I get
id_per_mov_table id_fk_pers id_fk_mov
1 2 1
2 80 2
3 80 3
4 80 4
So id_fk_pers is not getting the person id from the persons table. it is linked together with pers_id and id_fk_pers.
So what am I to do? I'm desperate to get this working.
I dont care how to do it but the goal is to show a detail page with one person and many movies with a ?pers_id link from another page.
Regards
Olle
ps. sorry for the long post -
I have an Item table and an Orders table linked for which I want to select certain Items and related Orders. The tables are linked via an Item No field. I want to select all items for which the total of (QOH + QOO - Reqmts) is negative. There can be multiple Orders for each item, or there can be no Orders for an item. The Items I want listed are those in the negative as stated above.
I have a formula which calculates Availability (QOH + open orders - requirements). QOH and requirements are straightforward and in the Items table. The open orders are a Running Total field for orders that are open and for which there is still a balance due.
My problem is that my report only lists those Items that have Orders associated with them. I also need Items that have no orders associated with them. When I tinker with the join type and the enforcement I get way too much data returned.
Are there any suggestions on how I can get the desired result?
Thanks.OK, I think I understand.
The problem you're facing here is that as soon as you use a field from the MOS table, you'll lose all the IM records which have no orders, because the MOS fields are all null for those records. Unless you 'protect' them, which is what I'm trying to explain.
The best place for you to start is with a simple query which doesn't include any fields from the MOS table, like {IM.IM_PROD_CODE} in "020" to "073". Try this without any MOS fields displayed in the report initially, and then add a couple. I don't think this will knock out your nulls, but it might. No formulas, just fields.
Now add the second line
and {MOS.MOS_STATUS} <= 1.00
This will knock out the nulls because you're accessing the MOS table in an unprotected way. The reason is that as soon as you use a null value in a formula, the record is automatically rejected.
But if you change your formula to something like this:
{IM.IM_PROD_CODE} in "020" to "073"
and ( isnull({MOS-IM-KEY})
or ( not isnull({MOS-IM-KEY} and {MOS.MOS_STATUS} <= 1.00 ) )
you should find that the null records stay.
Now if you've got another formula which accesses the MOS table, you need to cater for the nulls there too. For example, if you need to access the quantity of the item (lets say it's called Qty), you might need to do the following:
local numbervar Qty := if isnull({MOS.QTY} then 0 else {MOS.QTY};
and so on.
But because you're new to this you need to build it up slowly, watching that your null records don't disappear.
Andrew -
One to Many Conversion Problem
Hi Guys,
I have a source table and conataining different attributes. i want to do this thing
Source_Name=Targ_first name + Targ_Last name
Exp: Source name= Tanvir Mughal
I want to store in target table
targ_first_name=Tanvir
targ_last_name=Mughal
similer problem with address i want to break it into multiple fields
How i can do this. Should i write a query in expression operator if it is then please write that query. I am a student and working on a semester project.
Please help me i shall be thankful to you for this kind.This will work if you have 2 names only. If the guys name is 'AAAA BBBB CCCC', It won't work. Then, you'll have to use a LOOP to control it.
SQL> CREATE OR REPLACE PROCEDURE ONE_TO_MANY(V_FULL_NAME VARCHAR2) AS
2 V_FIRST_NAME VARCHAR2(50);
3 V_LAST_NAME VARCHAR2(50);
4 V_INI NUMBER;
5 V_END NUMBER;
6 V_LENGTH NUMBER;
7 BEGIN
8
9 V_LENGTH := LENGTH(V_FULL_NAME);
10 V_END := INSTR(V_FULL_NAME, ' ');
11 V_FIRST_NAME := SUBSTR(V_FULL_NAME, 1, (V_END-1));
12 V_LAST_NAME := SUBSTR(V_FULL_NAME, (V_END + 1), V_LENGTH);
13
14 DBMS_OUTPUT.PUT_LINE('FIRST NAME '||V_FIRST_NAME);
15 DBMS_OUTPUT.PUT_LINE('LAST NAME '||V_LAST_NAME);
16
17 END;
18
19 /
Procedure created.
SQL> set serveroutput on
SQL> EXEC ONE_TO_MANY('MARCOS FRANCO');
FIRST NAME MARCOS
LAST NAME FRANCO
PL/SQL procedure successfully completed. -
Problem Removing CMP 2.0 Bean from Many side of One-to-Many
I'm getting an exception within the weblogic container when I try to
delete a bean from the many side of a one-to-many CMR.
The two entity beans are called CaseFile and CaseExpert. There are
many CaseExperts for each CaseFile. When you call the remove method
on the CaseExpert, Weblogic throws a null pointer exception when
accessing the EntityCache as shown at the bottom of this message. I'm
using the latest version of Weblogic 7 (WebLogic Server 7.0 Thu Jun
20 11:47:11 PDT 2002 190955). My relationship section of my
ejb-jar.xml file is also shown below.
Any ideas?
Thanks,
David
[email protected]
javax.ejb.EJBException: EJB Exception:: java.lang.NullPointerException
at weblogic.ejb20.cache.TxKey.<init>(TxKey.java:30)
at weblogic.ejb20.cache.EntityCache.doGet(EntityCache.java:158)
at weblogic.ejb20.cache.EntityCache.get(EntityCache.java:118)
at weblogic.ejb20.manager.DBManager.getReadyBean(DBManager.java:252)
at weblogic.ejb20.manager.DBManager.lookup(DBManager.java:949)
at gov.usdoj.usa.ecms.casefile.exposure.ejb.CaseExpertBean_76ewyr__WebLo
gic_CMP_RDBMS.__WL_setCaseFile(CaseExpertBean_76ewyr__WebLogic_CMP_RDBMS.java:45
2)
at gov.usdoj.usa.ecms.casefile.exposure.ejb.CaseExpertBean_76ewyr__WebLo
gic_CMP_RDBMS.__WL_setCaseFile(CaseExpertBean_76ewyr__WebLogic_CMP_RDBMS.java:43
1)
at gov.usdoj.usa.ecms.casefile.exposure.ejb.CaseExpertBean_76ewyr__WebLo
gic_CMP_RDBMS.ejbRemove(CaseExpertBean_76ewyr__WebLogic_CMP_RDBMS.java:1978)
at weblogic.ejb20.manager.DBManager.remove(DBManager.java:876)
at weblogic.ejb20.internal.EntityEJBLocalObject.remove(EntityEJBLocalObj
ect.java:95)
<relationships>
<ejb-relation>
<ejb-relation-name>caseExpert-caseFile</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>CaseExpert-CaseFile</ejb-relationship-role-name>
<multiplicity>many</multiplicity>
<relationship-role-source>
<ejb-name>CaseExpertEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>caseFile</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>CaseFile-CaseExperts</ejb-relationship-role-name>
<multiplicity>one</multiplicity>
<relationship-role-source>
<ejb-name>CaseFileEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>caseExperts</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
</relationships>Wrong newsgroup, needs to go to one of the ejb newsgroups.
mbg
"Sai S Prasad" <[email protected]> wrote in message
news:3ec28167$[email protected]..
>
Hi,
I like to do the following:
1) Map one bean corresponding to table A to many beans corresponding totable
B 2) table B has two columns as the primary keys.
3) One of the primary key column in table B is a foreign key pointing tothe primary
key of table A.
4) bean corresponding to table A has the cmr Collection field
I am not able to map this scenario. I guess the mapping is possible aslong as
each table has its own unrelated primary keys. If anyone has tried this,please...please...help.
>
>
Thanks. -
One-to many relationship in EJB
hi forum
wish you a very happy and prosperous new year
i want to implement CMR in my project but to start with i tried sample application setting one-to many CMR between EMP and DEPT table of scott/tiger .the problem is i have to modify my orion-ejb-jar.xml how can we do it?Are you using JDeveloper? JDeveloper automatically creates the orion-ejb-jar.xml file when you use the EJB wizard.
-
JPA One-To-Many Parent-Child Mapping Problem
I am trying to map an existing legacy Oracle schema that involves a base class table and two subclass tables that are related by a one-to-many relationship which is of a parent-child nature.
The following exception is generated. Can anybody provide a suggestion to fix the problem?
Exception [EclipseLink-45] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Missing mapping for field [BASE_OBJECT.SAMPLE_ID].
Descriptor: RelationalDescriptor(domain.example.entity.Sample --> [DatabaseTable(BASE_OBJECT), DatabaseTable(SAMPLE)])
The schema is as follows:
CREATE TABLE BASE_OBJECT(
"BASE_OBJECT_ID" INTEGER PRIMARY KEY NOT NULL,
"NAME" VARCHAR2(128) NOT NULL,
"DESCRIPTION" CLOB NOT NULL,
"BASE_OBJECT_KIND" NUMBER(5,0) NOT NULL );
CREATE TABLE SAMPLE(
"SAMPLE_ID" INTEGER PRIMARY KEY NOT NULL,
"SAMPLE_TEXT" VARCHAR2(128) NOT NULL )
CREATE TABLE SAMPLE_ITEM(
"SAMPLE_ITEM_ID" INTEGER PRIMARY KEY NOT NULL,
"SAMPLE_ID" INTEGER NOT NULL,
"QUANTITY" INTEGER NOT NULL )
The entities are related as follows:
SAMPLE.SAMPLE_ID -> BASE_OBJECT.BASE_OBJECT_ID - The PKs that are used to join the sample to the base class
SAMPLE_ITEM.SAMPLE_ITEM_ID -> BASE_OBJECT.BASE_OBJECT_ID - The PKs that are used to join the sample item to the base class
SAMPLE_ITEM.SAMPLE_ID -> SAMPLE.SAMPLE_ID - The FK that is used to join the sample item to the sample class as a child of the parent.
SAMPLE is one to many SAMPLE_ITEM
The entity classes are as follows:
@Entity
@Table( name = "BASE_OBJECT" )
@Inheritance( strategy = InheritanceType.JOINED )
@DiscriminatorColumn( name = "BASE_KIND", discriminatorType = DiscriminatorType.INTEGER )
@DiscriminatorValue( "1" )
public class BaseObject
extends SoaEntity
@Id
@GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "BaseObjectIdSeqGen" )
@SequenceGenerator( name = "BaseObjectIdSeqGen", sequenceName = "BASE_OBJECT_PK_SEQ", allocationSize = 1 )
@Column( name = "BASE_ID" )
private long baseObjectId = 0;
@Entity
@Table( name = "SAMPLE" )
@PrimaryKeyJoinColumn( name = "SAMPLE_ID" )
@AttributeOverride(name="baseObjectId", column=@Column(name="SAMPLE_ID"))
@DiscriminatorValue( "2" )
public class Sample
extends BaseObject
@OneToMany( cascade = CascadeType.ALL )
@JoinColumn(name="SAMPLE_ID",referencedColumnName="SAMPLE_ID")
private List<SampleItem> sampleItem = new LinkedList<SampleItem>();
@Entity
@Table( name = "SAMPLE_ITEM" )
@PrimaryKeyJoinColumn( name = "SAMPLE_ITEM_ID" )
@AttributeOverride(name="baseObjectId", column=@Column(name="SAMPLE_ITEM_ID"))
@DiscriminatorValue( "3" )
public class SampleItem
extends BaseObject
@Basic( optional = false )
@Column( name = "SAMPLE_ID" )
private long sampleId = 0;
Edited by: Chris-R on Mar 2, 2010 4:45 PMThanks for the thoroughness. There was a mistake in moving the code over for the forum. The field names are correct throughout the original source code.
BASE_OBJECT_ID is used throughout.
I suspect the problem lies in the one-to-many sampleItem(s) relationship that is based upon the subclassed item class. (The relationship is actually "sampleItems" in the real code and somehow got changed in the move over.)
The problem may lie in the mapping of the attribute override in the child class to the referencing of the item class from the parent side of the relationship in the Sample class.
I further suspect this may be specific to Eclipselink based upon other postings I've seen on the web that have similar problems...
Any thoughts?
Edited by: Chris-R on Mar 3, 2010 9:56 AM -
One to many mappings delete problem
in using Toplink 9.0.3, I have modeled a simple one to many relationships and have ran into errors on deletion.
The following is an object model that fails to delete
diagram has one to many companies ( privately held )
companies have one to many ownerships ( privately held )
ownerships have a one to one to an owner company and an owned company ( not privately held ).
In the simplest scenario, Toplink knows how to delete a diagram. It will delete an ownership, then delete the companies and then delete the diagram.
However in a diagram where a company owns two companies, Toplink fails. It attempts to delete an owned company before deleting the parent Ownership.
Note that if toplink deleted the owner company then, it would know to delete the many ownerships first.
How do we tell toplink that on deleting a company,
1. delete all the ownerships in its one to many
2. and delete all the ownerships in which the company
plays the role as an owned company.
Note that deleting an ownership should not trigger a deletion of either the owner company or the owned company.
please contact at [email protected]Hello,
You appear to be missing a mapping in your object model.
TopLink decides its commit order, for both insertions and deletions based on the ONE TO ONE mappings in a project.
It appears that your company has no ONE TO ONE mapping to the diagram, which means that TopLink MAY decide to delete diagrams before it deletes companies.
I would suggest that you try adding a one to one mapping from company to diagram, correctly populated, and see if the problem recurs.
I hope this is of some help,
Christian
Maybe you are looking for
-
I keep getting the following message The iTunes library cannot be found or created. The default location for this file is in the iTunes folder in the music folder. All of my playlists have disappeared and I am trying to recover them however I now can
-
Setting icon for buttons in labview 6i
Hi All, Currently i am working on Labview 6i. i created two buttons in my vi one button is used to perform the test, another will be used to exit from the test. i would like to add icons for those buttons. can anyone tell me how to add icons for butt
-
Blank screen no external display
My satellite is less than one year old. On start, screen is blank, external display does not work. Potentially motherboard issues. This appears to be common. Will they pay money back instead of repairing and returning the.horrible product? It may bre
-
Notes Multiply alarmingly - from 10 Notes to 300,000
Mail has been really problematic foe me recently (refuses to Quit unless ForceQuit, hogs up all CPU, is sluggish in general and clicking on Notes and ToDos crashes Mail.) I have tried various remedies (rebuilt Mailboxes, trashed Preferences, stopped
-
Unable to create KM transport package
In Content Admin>KM Content> Exports>Archived exports> user cant see anything in Archives and log is showing error: 01-Jul-2009 03:12:27 Info Starting export "static content - Facilities" (003aebeb-1a48-2c10-2bb8-cffcc4b5861e) using mode "Fil