An Internal Error Occurred Accessing The Primary Key Object
Things LocationTech Long-Term Support PolarSys Science OpenMDM More Community Marketplace Events Planet Eclipse Newsletter Videos Participate Report a Bug Forums Mailing Lists Wiki IRC How to Contribute Working Groups Automotive Internet of Things LocationTech Long-Term Support PolarSys Science OpenMDM Toggle navigation Home Projects Forums Eclipse Community Forums Forum Search: Search Help Register Login Home Home» Eclipse Projects» EclipseLink» Composite Key Configuration using Dynamic Eclipse Link API Show: Today's Messages :: Show Polls :: Message Navigator Composite Key Configuration using Dynamic Eclipse Link API [message #784225] Fri, 27 January 2012 08:08 Nabeel AhmedMessages: 20Registered: January 2012 Junior Member I m try to configure a Dynamic Type which have composite primary key, but i am having a problem in its configuration. /* * Configuring ProductKey */ JPADynamicTypeBuilder productKeyTypeBuilder = new JPADynamicTypeBuilder(classLoader.createDynamicClass(packageName + "ProductKey"), null); productKeyTypeBuilder.addDirectMapping("ProductID", int.class,"ProductID"); productKeyTypeBuilder.addDirectMapping("ProductName", String.class, "ProductName"); /* * Configuring Products */ JPADynamicTypeBuilder productTypeBuilder = new JPADynamicTypeBuilder(classLoader.createDynamicClass(packageName + "Products"), null, "Products"); productTypeBuilder.addDirectMapping("QuantityPerUnit", String.class,"QuantityPerUnit"); productTypeBuilder.addDirectMapping("UnitPrice", Double.class, "UnitPrice"); productTypeBuilder.addDirectMapping("UnitsInStock", Short.class, "UnitsInStock"); productTypeBuilder.addDirectMapping("UnitsOnOrder", Short.class, "UnitsOnOrder"); productTypeBuilder.addDirectMapping("ReorderLevel", Short.class, "ReorderLevel"); productTypeBuilder.addDirectMapping("Discontinued", Boolean.class, "Discontinued"); AggregateObjectMapping aom = productTypeBuilder.addAggregateObjectMapping("ProductKey", productKeyTypeBuilder.getType(), true); aom.setIsPrimaryKeyMapping(true); aom.setIsReadOnly(false); and i m getting errors in it. am i missing anything? any help? Report message to a moderator Re: Composite Key Configuration using Dynamic Eclipse Link API [message #786491 is a reply to message #784225] Mon, 30 January 2012 13:52 Nabeel AhmedMessages: 20Registered: January 2012 Junior Member I m still facing this problem, please help me in this regard Repo
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, https://www.eclipse.org/forums/index.php/t/279854/ helping each other. Join them; it only takes a minute: Sign up Overwritten field when persisting with JPA up vote 4 down vote favorite When testing the persistence of my model I'm getting one attribute overwritten. I'm running the following test: @Test public void objectTest() throws Exception { tester.testClass(AssetUpdateReserve.class); Assert.assertEquals(tester.getResult().getErrors().size(), 0, "Errors found"); } My AssetUpdateReserve Entity: http://stackoverflow.com/questions/24560085/overwritten-field-when-persisting-with-jpa @Entity @Table(name = "ASSET_UPD_RESERVE") public class AssetUpdateReserve implements Serializable { private static final long serialVersionUID = 6530799190088978893L; @EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "partitionId.assetSliceId", column = @Column(name = "PARTITION_ID")), @AttributeOverride(name = "partitionId.associatedKey", column = @Column(name = "PARTITION_ID_AK")), @AttributeOverride(name = "containerId.id", column = @Column(name = "CONTAINER_ID")), @AttributeOverride(name = "containerId.associatedKey", column = @Column(name = "CONTAINER_ID_AK")) }) private AssetUpdateReserveIndex id; // Default JSON/JAXB constructor public AssetUpdateReserve() { } } According to this I should have a primary key with four attributes. However, the same name in the associatedKey makes one of the attributes to be overwritten (in this particular case, CONTAINER_ID_AK overwrites PARTITION_AD_AK) That makes my primary key have only three fields. I've tried to comment the last @AttributeOverride, this fixes the problem and the table has the PARTITION_ID_AK column. However, I can't just dismiss the CONTAINER_ID_AK. My other entities: AssetSliceId @Embeddable public class AssetSliceId implements Serializable { private static final long serialVersionUID = 9065665917069565503L; public static final int MAX_VALUE = Integer.MAX_VALUE; @Column(name = "ASSET_SLICE_ID") private Integer assetSliceId; @Column(name = "ID_AK") private String ass
CommunityOracle User Group CommunityTopliners CommunityOTN Speaker BureauJava CommunityError: You don't have JavaScript enabled. This tool uses JavaScript and much of it will not work correctly without it enabled. Please turn JavaScript back on and reload this page. Please enter a title. You can not post a blank https://community.oracle.com/thread/2162931?start=0 message. Please type your message and try again. More discussions in TopLink/JPA All PlacesFusion MiddlewareApplication ServerTopLink/JPA This discussion is archived 5 Replies Latest reply on Feb 2, 2011 2:57 AM by 813474 Problem in persisting https://eclipse.googlesource.com/eclipselink/eclipselink.runtime/+/2.5/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/i18n/DescriptorExceptionResource.java related entities using TopLink Grid Entity 813474 Jan 20, 2011 2:34 AM I am now working with entities with OneToMany relationship using TopLink Grid Entity and make use of the write behind feature. My example an internal is, I have ClassA which has a OneToMany mapping to ClassB. Then from my client application, I create 1 ClassA and ClassB instance, and put the ClassB into the list in ClassA. Later I persist the ClassA object. From the EclipseLinkJPACacheStore at the Coherence Server side, I found it tries to persist 2 objects: 1. ClassA instance, with a ClassB in its list but the fields are empty. 2. an internal error ClassB instance And from the debug log of EclipseLink, ClassA is inserted more than 1 times which cause integrity error in the DB. Would it be a problem of Coherence? CacheStore? or my entites JPA annotations? When I am not using TopLink Grid, everything works fine with EclipseLink only. Thanks. ----- Object received in EclipseLinkJPACacheStore: (after unwrap) 1. ClassA [ id :111, code:A24FDA, name:nameTag, List Class B : [ ClassB [ id :, coName:, price :null ], ]] 2. ClassB [ id :111, coName:CCC, price :123 ] ----- SQL run by EclipseLink (excluded select) INSERT INTO ClassA (id, name, code) VALUES (?, ?, ?) bind => [111, null, null] INSERT INTO ClassB (id, co_name, price) VALUES (?, ?, ?) bind => [111, CCC, 123] INSERT INTO ClassA (id, name, code) VALUES (?, ?, ?) bind => [111, name 2, A24FDA] The 1st SQL is weird to insert null to everything other than the key. The 3rd SQL is causing the duplicate key. ----- Version I use: EclipseLink: 2.1.2 TopLink: 11.1.1.4.0 Coherence: 3.6.1 ----- My entites: @Entity @Table(name="ClassA") @Cacheable @Customizer(CoherenceReadWriteCustomizer.class) public class ClassA implements Serializable, PortableObject { private static final long serialVersionUID = -1535466991451378483L; private Map
[log] [blame]/******************************************************************************* * Copyright (c) 1998, 2014 Oracle, IBM Corporation and/or its affiliates. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 * which accompanies this distribution. * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html * and the Eclipse Distribution License is available at * http://www.eclipse.org/org/documents/edl-v10.php. * * Contributors: * Oracle - initial API and implementation from Oracle TopLink * 10/15/2010-2.2 Guy Pelletier * - 322008: Improve usability of additional criteria applied to queries at the session/EM * 09/24/2014-2.6 Rick Curtis * - 443762 : Misc message cleanup. ******************************************************************************/ package org.eclipse.persistence.exceptions.i18n; import java.util.ListResourceBundle; /** * INTERNAL: * English ResourceBundle for DescriptorException messages. * * Creation date: (12/8/00 4:47:38 PM) * @author: Rick Barkhouse */ public class DescriptorExceptionResource extends ListResourceBundle { static final Object[][] contents = { { "1", "The attribute [{0}] is not declared as type ValueHolderInterface, but its mapping uses indirection." }, { "2", "The attribute [{0}] is declared as type ValueHolderInterface, but its mapping does not use indirection." }, { "6", "Attribute name is missing." }, { "7", "The attribute [{0}] should be a type that implements {1}." }, { "8", "The descriptor [{0}] has been set to use inheritance, but a class indicator field has not been defined. {2}When using inheritance, a class indicator field or class extraction method must be set. {2}Parent Descriptor: [{1}]" }, { "9", "This mapping does not have a direct field name set." }, { "10", "This mapping does not have a field name set." }, { "11", "The foreign key information for this mapping is defined incorrectly." }, { "12", "Descriptors must use an identity map in order to use the \"Check Cache\" existence checking option." }, { "13", "The instance variable [{