JPA Bug !?
Hi,
I'm building a web shop using JPA.
A couple of my entities are Category(as in category of items) and Item. Here is a minimized code preview :
@Entity
@Table(name = "category")
@NamedQueries(....)
public class Category implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = true, fetch = FetchType.EAGER)
@Column(name = "categoryId")
private Integer categoryId;
@OneToMany(mappedBy = "categoryId", cascade = CascadeType.REMOVE)
private List<Item> itemCollection;
@Entity
@Table(name = "item")
@NamedQueries(....)
public class Item implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = true, fetch = FetchType.EAGER)
@Column(name = "itemId")
private Integer itemId;
@JoinColumn(name = "categoryId", referencedColumnName = "categoryId", updatable=true)
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
private Category categoryId;
Now my problem is that, after creating a new Item, this method doesn't return it :
public List<Item> getItemsByCategory(int categoryId) {
Category category = (Category)entityManager.createNamedQuery("Category.findByCategoryId").setParameter("categoryId", categoryId).getSingleResult();
List<Item> itemsOfThisCat = category.getItemCollection();
return itemsOfThisCat;
Just to make it clear, there is no error, the newly created Item is in db, but it is returned by the above method only if restart the server or redeploy the application !!!!?
I have this problem both for TopLink and OpenJPA, and I am completing the entire project by my self, from the web design to the db optimization, so I could really use a good and concise advice.
Cheers,
Cristi
I found it natural that JPA will add by itself a newly created Item to the List<Item> of the Category entity.
I hate it when I get stuck in such small issues, thank u so much for your reply.
Similar Messages
-
Weird issue with merge using JPA...?
Hi all,
I have the following code snippet (HsTrans has a manytoone relation with Hss), Hss is the parent
HsTrans hsTrans = new HsTrans();
Hss hss=em.find(Hss.class, studyId);
hsTrans.setStudy(studyId);
hsTrans.setState(state.toString());
hsTrans.setTimestamp(timeOfState);
hss.getHsTrans().add(hsTrans); //Add child to aprent
hsTrans.setHss(hss); //Child Parent
em.merge(hss); // Does not work Throws a Unique Key violation error
Whereas replacing the same with this
Hss hss2=hsStudyTrans.getHsStudy();
em.merge(hss2); // Works fine
Does anyone know if this is a JPA bug or some other issue.
Thx
VRRainaV wrote:
Does anyone know if this is a JPA bug or some other issue.JPA is a specification, so it has no bugs (only design flaws). If there is a bug somewhere it is in the persistence provider you are using, but most likely it is just you not understanding how merge and transaction management in general works. I've written dozens of applications now that use JPA and I think I really needed merge a grand total of once.
In this snippet you provide, you are apparently making the 'hss' object managed through the em.find() method. This means that any changes you make to it will be made persistent as soon as the transaction is committed. You don't need to call merge() at all, you only call that on entities that are detached.
Now for the actual problem of unique key violation, I don't even see you committing hsTrans. Change the code to this:
HsTrans hsTrans = new HsTrans();
Hss hss=em.find(Hss.class, studyId);
hsTrans.setStudy(studyId);
hsTrans.setState(state.toString());
hsTrans.setTimestamp(timeOfState);
hsTrans.setHss(hss); // set managed hss object
em.persist(hsTrans); // persist hsTrans and make it managed
hss.getHsTrans().add(hsTrans); // add the new managed hsTrans to the hss mapped collection -
OneToMany relation over composite PK query error
We have two classes with composite PK's on both sides. The classes are related via OneToMany relation (and ManyToOne vice versa). The mapping basically works, but if a simple query is issued like
"select stp from Teilstp stp"
we get the strange error message "Exception Description: The parameter name [tstnr2] in the query's selection criteria does not match any parameter name defined in the query." Query: ReadAllQuery(lager.model.Teillgp)
As there are no parameters defined in the query above, this seems to be some kind of internal TopLink JPA error.
We are unsure whether our mapping is the problem or if the error could be caused by a TopLink JPA bug? Please have a look at the code snippets below and verify the mappings!
regards,
Hans
@IdClass(TeilstpPK.class)
@Entity
@Table(name = "teilstp", schema = "jws")
public class Teilstp {
@Id
private String tstnr1;
@Id
private String tstnr2;
@Id
private String tstnr3;
@Id
private String tstnr4;
@Id
private String tstnr5;
@Basic
@Column(name = "tsmeh")
private String tsmeh;
@Basic
@Column(name = "tsdekp")
private Double tsdekp;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY,mappedBy="stp")
private Set<Teillgp> lgps;
@IdClass(TeillgpPK.class)
@Entity
@Table(schema = "jws")
public class Teillgp {
@Id
private String tltnr1;
@Id
private String tltnr2;
@Id
private String tltnr3;
@Id
private String tltnr4;
@Id
private String tltnr5;
@Id
private Long tllgnr;
@Basic
private Double tllgbs;
@ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
@JoinColumns( {
@JoinColumn(name = "tltnr1", referencedColumnName = "tstnr1"),
@JoinColumn(name = "tltnr2", referencedColumnName = "tstnr2"),
@JoinColumn(name = "tltnr3", referencedColumnName = "tstnr3"),
@JoinColumn(name = "tltnr4", referencedColumnName = "tstnr4"),
@JoinColumn(name = "tltnr5", referencedColumnName = "tstnr5") })
private Teilstp stp;
The PrimaryKey @IdClasses are just plain pojo's with hashCode and equals implemented.
Invoking Teilstp.getLgps() fails with:
[TopLink Warning]: 2007.06.11 03:48:50.640--ServerSession(11582167)--Exception [TOPLINK-6094] (Oracle TopLink Essentials - 2.0 (Build b38-rc (03/07/2007))): oracle.toplink.essentials.exceptions.QueryException
Exception Description: The parameter name [tstnr2] in the query's selection criteria does not match any parameter name defined in the query.
Query: ReadAllQuery(lager.model.Teillgp)
Any ideas?I have this same error, except mine occurs when I make use of the @OneToMany Set.
This problem seems to be related to connecting Entity Relationships (Specifically ManyToOne) to Id fields.
(And I have the most recent version as of June 2007)
(Also, I know this post is five years old, but it was the sole result on Google)
I bet your stack trace looks somewhat like this:
oracle.toplink.essentials.exceptions.QueryException.parameterNameMismatch(QueryException.java:983)
oracle.toplink.essentials.internal.expressions.ParameterExpression.getValue(ParameterExpression.java:231)
oracle.toplink.essentials.internal.databaseaccess.DatabaseCall.translate(DatabaseCall.java:837)
oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:215)
oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:286)
oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:616)
oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2417)
oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2395)
oracle.toplink.essentials.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:339)
oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:725)
oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:629)
oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:693)
oracle.toplink.essentials.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:1831)
oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:953)
oracle.toplink.essentials.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:102)
oracle.toplink.essentials.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:92)
oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:106)
oracle.toplink.essentials.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:176)
oracle.toplink.essentials.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:248)
oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:106)
oracle.toplink.essentials.indirection.IndirectSet.buildDelegate(IndirectSet.java:194)
oracle.toplink.essentials.indirection.IndirectSet.getDelegate(IndirectSet.java:309)
oracle.toplink.essentials.indirection.IndirectSet$1.<init>(IndirectSet.java:360)
oracle.toplink.essentials.indirection.IndirectSet.iterator(IndirectSet.java:359) -
JPA OnetoMany QUERY LEFT JOIN BUG
Using JPA in JDev 10.1.3.1.0.3984
Database: Firebird 1.51LI-V1.5.3.4870 Firebird 1.5/tcp
Driver: Jaybird JCA/JDBC driver Version: 2.1
TopLink, version: Oracle TopLink Essentials - 2006.8 (Build 060829)
If I use normal JOIN it works.
On LEFT JOIN I get a {oj [/b] before the table name and a [b]} at the end.
public class Cliente{
@OneToMany(mappedBy = "cliente")
@JoinColumn(name = "CDCLIENTE", referencedColumnName = "CDCLIENTEREQUISITANTE")
private List<Requisicao> requisicoes;
public class Requisicao
@ManyToOne
@JoinColumn(name = "CDCLIENTEREQUISITANTE", referencedColumnName = "CDCLIENTE")
private Cliente cliente;
EntityManager em = getEntityManager();
String sql = "SELECT c FROM Cliente c LEFT JOIN c.requisicoes req";
Query q = em.createQuery(sql);
List rs = q.getResultList();Result SQL:
SELECT DISTINCT t0. <OMITTED> FROM {oj [/b]CLIENTE t0 LEFT OUTER JOIN REQUISICAO t1 ON (t1.CDCLIENTEREQUISITANTE = t0.CDCLIENTE)[b]}You cannot define an ON clause with Criteria, nor JPQL.
Perhaps you can reword the query to avoid needing an ON clause.
What is the query you want to do (in english)?
Can you just use an OR in the where clause?
There is a enhancement request to have ON clause support added, please vote for it.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=312146
James : http://www.eclipselink.org -
JPA Metadata issue/ Weird Column error or bug in openjpa ...?
Hi All,
I am getting the following exception when using openjpa in my project.
The line of code that throws the error is also mentioned
The latter error shows a column mismatch error which i am not sure is correct since the db i am using is Oracle 10g and the datatypes for the column are varchar2.
BcsPort bcsPort=em.find(BcsPort .class, port); //Error after this call.
EJB Exception: : <openjpa-1.1.1-SNAPSHOT-r422266:965591 fatal user error> org.apache.openjpa.per
sistence.ArgumentException: Errors encountered while resolving metadata. See nested exceptions for details.
at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:567)
at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308)
at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1121)
at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:268)
at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:451)
at sun.reflect.GeneratedMethodAccessor472.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:93)
at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:91)
at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:26)
at $Proxy76.find(Unknown Source)
.... so onFollowed by this as the cause from what i can make
Caused by: <openjpa-1.1.1-SNAPSHOT-r422266:965591 fatal user error> org.apache.openjpa.persistence.ArgumentException: "
com.test.domain.BcsNe.ne" declares a column that is not compatible with the expected type "varchar". Column detail
s:
Full Name: bcsne.ne
Type: blob
Size: 0
Default: null
Not Null: false
at org.apache.openjpa.jdbc.meta.MappingInfo.mergeColumn(MappingInfo.java:660)
at org.apache.openjpa.jdbc.meta.MappingInfo.createColumns(MappingInfo.java:518)
at org.apache.openjpa.jdbc.meta.ValueMappingInfo.getColumns(ValueMappingInfo.java:143)
at org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy.map(StringFieldStrategy.java:79)
at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:120)
at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:80)
at org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:438)
at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:403)
at org.apache.openjpa.jdbc.meta.ClassMapping.resolveNonRelationMappings(ClassMapping.java:834)
at org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:324)
at org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:667)
at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:549)
... 78 moreI have seen this link https://issues.apache.org/jira/browse/OPENJPA-1481
Can anyone help me out on this as i cannot make out if this is a problem in openjpa or the weblogic server 10.0 server
that i am using to make the call..
Any inputs on this highly appraciatedgimbal2 wrote:
That link seems to deal with a bug relating to a one to many mapping. I don't see anywhere in your post that you are dealing with the same thing.
Actually i am using Many to One mapping as you can see from the code excerpt
BcsPort
@ManyToOne(optional=false, cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="ne",referencedColumnName="ne")
private BcsNe bcsNe;Why i posted the link was that it seems to throw the same weird column exception that i got and more googling revelead that it was indeed some issue between the way the oracle varchar2 field is being handled by openjpa.
so just needed to confirm if this was a widely faced issue and a possible fix to the same
Is there a particular reason why you are using openjpaActually it's been added recenlty to the system as before it was using normal JDBC Code...
In stead of the persistence provider shipped with your JEE container anyway?Do you mean that i should use the Oracle Weblogic 10.3 persistence provider...?
kindly suggest...
thanks -
Bug on EJB/JPA creation process
Hi.
Using JDK 1.5.0.10, KUbuntu Feisty, JDev 11.1.1.0.0.
I run the "Entities From Table" wizard in order to create two entities. All table names begin with a trigram so at the "Specify Entity Details" step I rename the entities from, say, Den_Foo and Den_Bar to Foo and Bar. The "Summary" step looks ok so I finish the wizard.
Now, just one entity gets created and no tables are added to the offline database. The one entity has a sole ctor and no fields.
Note that this does happen if the two tables are related (master-detail relationship). If the two tables are irrelevant then no problem.
The console windows shows no errors.
Another bug (or is it a feature?) of the same wizard is that although I select Online Database Connection as "Type of Conenction", an offline database gets created/used anyway.
Denis
PS so far, congrats for the new JDev !!!Hi
The script that defines two tables (DLK_PACKAGES, DLK_PACKAGECOVERS) is at the end of the msg.
Steps to produce the bug:
0. Prepare the datasource (say, "denis"), go to the Entities From Table wizard
1. Accepting all the defaults using "Next".
2. At "Select tables" I select the two included and Next
3. At "Specify Entity Details" I change a) DlkPackagecovers to PackageCovers and b) DlkPackages to InsPackages and Next
4. The "Summary" is set up ok
After Finish
a. I get PackageCovers.java without any field defintion, just a ctor
b. No InsPackages.java
c. No offline database tables
NB that I am rewritting a 10.1.3.2 demo that I ran a billion times over the past two months so I follow the exact philosophy that used to work.
Thx
Denis
CREATE TABLE DLK_PACKAGES (
[PKGID]numeric(18, 0) NOT NULL,
[PKGCODE]char(10) COLLATE SQL_Latin1_General_CP1253_CI_AS NOT NULL,
[PKGDESCRIPTION]char(50) COLLATE SQL_Latin1_General_CP1253_CI_AS NOT NULL,
[PKGKIND]char(10) COLLATE SQL_Latin1_General_CP1253_CI_AS NULL,
[PKGTMSTMP]datetime CONSTRAINT [DF_DLK_PACKAGES_PKGTMSTMP] DEFAULT getdate() NOT NULL,
[PKGINSCOMPID]int NOT NULL,
CONSTRAINT [IX_DLK_PACKAGES] UNIQUE ([PKGDESCRIPTION]),
CONSTRAINT [PK_DLK_PACKAGES] PRIMARY KEY CLUSTERED ([PKGID])
ON [PRIMARY]
GO
CREATE TABLE [dbo].[DLK_PACKAGECOVERS] (
[PGCID]numeric(18, 0) NOT NULL,
[PGCTYPE]int NOT NULL,
[PGCCAPITALTYPE]int NOT NULL,
[PGCCAPITALVALUES]varchar(50) COLLATE SQL_Latin1_General_CP1253_CI_AS NOT NULL,
[PGCDISCHARGETYPE]int NULL,
[PGCDISCHARGEVALUES]varchar(50) COLLATE SQL_Latin1_General_CP1253_CI_AS NULL,
[PGCMUSTCOVERS]varchar(50) COLLATE SQL_Latin1_General_CP1253_CI_AS NULL,
[PGCINSCOMPID]int NOT NULL,
[PGCPKGID]numeric(18, 0) NOT NULL,
[PGCCOVERID]int NOT NULL,
[PGCBRANCHID]smallint NOT NULL,
CONSTRAINT [PK_DLK_PACKAGECOVERS] PRIMARY KEY CLUSTERED ([PGCID]),
CONSTRAINT [FK_DLK_PACKAGECOVERS_DLK_PACKAGES] FOREIGN KEY ([PGCPKGID])
REFERENCES [dbo].[DLK_PACKAGES] ([PKGID])
ON UPDATE NO ACTION
ON DELETE NO ACTION
ON [PRIMARY]
GO -
EJB 3.0 JPA Entities and preserving user identities
Hello all,
I've been reading about some of the techniques available to Oracle DB developers to ensure that some sense of a user's real identity is maintained in multitier applications (<http://download-uk.oracle.com/docs/cd/B19306_01/network.102/b14266/apdvprxy.htm>).
I was wondering if either of the methods described (proxy authentication or the use of the CLIENT_IDENTIFIER attribute) could be used in conjunction with EJB 3.0 JPA Entity beans (in an OC4J container).
If so, I would really appreciate any pointers to useful documentation! I've read something about the use of proxy authentication with TopLink (<http://www.oracle.com/technology/products/ias/toplink/doc/11110/relnotes/toplink-relnotes.html#BABHEFEF>), but I'm not sure how this relates to the use of Entity beans.
Many thanks,
Alistair.Just to close this thread out...
Under another thread: <JPA Entities with Proxy Authentication / OC4J bug it was determined that this is NOT possible with OC4J 10g, but should be supported by 11g.
Alistair. -
A potential bug on the new feature (12c) of Identity Column?
Hi,
I am testing a newly introduced feature of Identity Column in Oracle 12c. I used EclipseLink (JPA) to access the database.
I may have found a potential bug with this feature. I am getting "ORA-30667: cannot drop NOT NULL constraint on a DEFAULT ON NULL column" when I try to insert a row. My code doesn't explicitly drop "NOT NULL" constraint.
When I delete all the tables under the user and re-define the user and the tables, the error disappear.
Here are the details:
Error:
DatabaseException Internal Exception: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 ORA-30667: cannot drop NOT NULL constraint on a DEFAULT ON NULL column Error Code: 604 Call: INSERT INTO MyTable (ID, SOMEID, SOMEDATE) VALUES (?, ?, ?) bind => [null, 100100147, 2013-11-29 Query: InsertObjectQuery(cus.entity.MyTable@1a9ea5b)
Table definition:
CREATE TABLE MyTable (id NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY PRIMARY KEY,
someId INT NOT NULL,
someDate DATE NOT NULL,
PARTITION BY range(someDate)
interval(numtodsinterval(1,'year'))
SUBPARTITION BY HASH ( someId)
SUBPARTITIONS 20
PARTITION p0 VALUES LESS THAN (TO_DATE('01-12-2013', 'DD-MM-YYYY'))
Could anyone tell me if there might be a bug associated with the new feature or if there was something wrong with my code?
I would be appreciated if anyone can help."here is a reproducible test case in the SCOTT schema - if it reproduces for you open an SR with Oracle"
Yes. I have just followed the instruction you posted and managed to re-produce the same error I reported earlier. Here are the details of the script output following your posted instruction:
table MYTABLE dropped.
purge recyclebin
table MYTABLE created.
1 rows inserted.
table MYTABLE dropped.
OBJECT_NAME ORIGINAL_NAME OPERATION TYPE TS_NAME CREATETIME DROPTIME DROPSCN PARTITION_NAME CAN_UNDROP CAN_PURGE RELATED BASE_OBJECT PURGE_OBJECT SPACE
BIN$6NCDTxmXTb2QBpUWF0kGqw==$0 SYS_C0010655 DROP INDEX USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030808 NO YES 98789 98789 98812 8
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:30:56 2013-12-01:10:32:17 4030812 NO NO 98790 98789 98789 0
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:31:37 2013-12-01:10:32:17 4030812 NO NO 98833 98789 98789 1024
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:31:37 2013-12-01:10:32:17 4030812 NO NO 98833 98789 98789 1024
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:31:37 2013-12-01:10:32:17 4030812 NO NO 98833 98789 98789 1024
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:31:37 2013-12-01:10:32:17 4030812 NO NO 98833 98789 98789 1024
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:31:37 2013-12-01:10:32:17 4030812 NO NO 98833 98789 98789 1024
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:31:37 2013-12-01:10:32:17 4030812 NO NO 98833 98789 98789 1024
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:31:37 2013-12-01:10:32:17 4030812 NO NO 98833 98789 98789 1024
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:31:37 2013-12-01:10:32:17 4030812 NO NO 98833 98789 98789 1024
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:31:37 2013-12-01:10:32:17 4030812 NO NO 98833 98789 98789 1024
BIN$Ka0sgN7XRBeCsjyXTQ76cA==$0 MYTABLE DROP Table Composite Partition USERS 2013-12-01:10:31:37 2013-12-01:10:32:17 4030812 & -
JPA Error with SDO_GEOMETRY conversion
Attempted to perform a native SQL query which invokes
the Oracle SDO_UTIL.ELLIPSE_POLYGON() function within
a JPA context and got a ClassCastException. Here is code snippet:
try
javax.persistence.Query query = entityManager_.createNativeQuery(
"select SDO_UTIL.ELLIPSE_POLYGON( 32.4, 112.6, 1124.2, 992.4, 18.0, 5.0 ) from DUAL" );
oracle.sql.STRUCT obj = ( oracle.sql.STRUCT ) query.getSingleResult();
}catch( Exception e ) {}
When the query is executed this error occurs:
ERROR: java.lang.ClassCastException: org.eclipse.persistence.internal.helper.NonSynchronizedVector cannot be
cast to oracle.sql.STRUCT
NOTE: using Toplink 11G
Thanks ...
Edited by: user11177655 on Jul 22, 2009 12:45 PMI assume you are getting back a List (Vector) with the Struct inside it. Try ((List)query.getSingleResult()).get(0).
In JPA you should get the Struct back directly if the result size was 1, otherwise an Object[], this was a bug in EclipseLink 1.0 that was fixed in EclipseLink 1.1.
You should probably upgrade to EclipseLink 1.1.
James : http://www.eclipselink.org -
How to determine the exact database error in JPA?
For example you are going to add a record in the database which primary already exist
in one of the records in that table in the database. This will cause an error, but how do
I know this error in human readable form just like "Same record with the same PK in the
the table already exist" in JPA.
My current procedure is that I will first check all the records in the database in that table
and compare those PK's in the current record, if there is a conflict then I know the error.
But this procedure is so slow considering there are a lot of records in the database.
Fetch and compare is so slow.
Anyone help me on this.For example you are going to add a record in the database which primary already existin one of the records in that table in the database. This will cause an error, but how do
I know this error in human readable form just like "Same record with the same PK in the
the table already exist" in JPA>
Why would you do that though? If you're using autogenerated keys it can't occur. If you're using business keys you should be checking for the existence of the key before trying to insert. Any other case is likely to be a bug, so don't do that. -
JDeveloper, JPA named query String parameter with length of 1
Hi,
I use JDeveloper 11.1.1.2.0. and have the following table:
CREATE SEQUENCE COUNTRY_SEQ;
CREATE TABLE COUNTRY (
COUNTRY_ID NUMBER NOT NULL,
COUNTRY_NAME VARCHAR2(40),
COUNTRY_CODE CHAR(2) NOT NULL,
CONSTRAINT COUNTRY_ID_PK PRIMARY KEY (COUNTRY_ID)
INSERT INTO COUNTRY VALUES (COUNTRY_SEQ.NEXTVAL, 'Belgium', 'B');
INSERT INTO COUNTRY VALUES (COUNTRY_SEQ.NEXTVAL, 'Netherlands', 'NL');
COMMIT;
I made a JPA Entity with two queries:
@NamedQueries({
@NamedQuery(name = "Country.findAll", query = "select o from Country o"),
@NamedQuery(name = "Country.findByCountryCode", query = "select o from Country o where o.countryCode = 'B' or o.countryCode ='NL'")
The first works fine, gives back both B and NL. But the second gives back only NL. I have no clue why.
If I change 'B' to 'BE' both in the DB and the code, it works. If I change to 'b', it doesn't. So it seems that the problem comes with 1 char long Strings.
Is it an EclipseLink bug?
I use Oracle Database 11g Enterprise Edition Release 11.1.0.7.0. But
SELECT COUNTRY_ID, COUNTRY_NAME, COUNTRY_CODE FROM COUNTRY WHERE COUNTRY_CODE = 'B' OR COUNTRY_CODE = 'NL';
works in SQL*Plus.
Thx, DonatHi,
That's true, it uses value bindings while the values are hard coded. I use the default EclipseLink embedded into JDeveloper 11.1.1.2, with the default settings. The JPA bean runs in the default embedded WebLogic of JDeveloper. This might be a default setting of EclipseLink to use bindings for hard coded values.
Here is a fragment of Country.java:
@Entity
@NamedQueries({
//@NamedQuery(name = "Country.findAll", query = "select o from Country o")
@NamedQuery(name = "Country.findAll", query = "select o from Country o where o.countryCode ='B' or o.countryCode ='NL'")
public class Country implements Serializable {
@Id
@Column(name="COUNTRY_ID", nullable = false)
private Long countryId;
@Column(name="COUNTRY_CODE", nullable = false)
private String countryCode;
@Column(name="COUNTRY_NAME", length = 40)
private String countryName;
And I have a JavaServiceFacade.java:
public class JavaServiceFacade {
private EntityManagerFactory emf = Persistence.createEntityManagerFactory("EjbModel-1-Outside");
public JavaServiceFacade() {
public static void main(String [] args) {
final JavaServiceFacade javaServiceFacade = new JavaServiceFacade();
List<Country> countries;
countries = javaServiceFacade.getCountryFindAll();
for (Country country : countries) {
System.out.println(country.getCountryCode());
private EntityManager getEntityManager() {
return emf.createEntityManager();
/** <code>select o from Country o</code> */
public List<Country> getCountryFindAll() {
return getEntityManager().createNamedQuery("Country.findAll").getResultList();
BR, Donat -
JPA named query String parameter with length of 1
Hi,
I use JDeveloper 11.1.1.2.0. and have the following table:
CREATE SEQUENCE COUNTRY_SEQ;
CREATE TABLE COUNTRY (
COUNTRY_ID NUMBER NOT NULL,
COUNTRY_NAME VARCHAR2(40),
COUNTRY_CODE CHAR(2) NOT NULL,
CONSTRAINT COUNTRY_ID_PK PRIMARY KEY (COUNTRY_ID)
INSERT INTO COUNTRY VALUES (COUNTRY_SEQ.NEXTVAL, 'Belgium', 'B');
INSERT INTO COUNTRY VALUES (COUNTRY_SEQ.NEXTVAL, 'Netherlands', 'NL');
COMMIT;
I made a JPA Entity with two queries:
@NamedQueries({
@NamedQuery(name = "Country.findAll", query = "select o from Country o"),
@NamedQuery(name = "Country.findByCountryCode", query = "select o from Country o where o.countryCode = 'B' or o.countryCode ='NL'")
The first works fine, gives back both B and NL. But the second gives back only NL. I have no clue why.
If I change 'B' to 'BE' both in the DB and the code, it works. If I change to 'b', it doesn't. So it seems that the problem comes with 1 char long Strings.
Is it an EclipseLink bug?
I use Oracle Database 11g Enterprise Edition Release 11.1.0.7.0. But
SELECT COUNTRY_ID, COUNTRY_NAME, COUNTRY_CODE FROM COUNTRY WHERE COUNTRY_CODE = 'B' OR COUNTRY_CODE = 'NL';
works in SQL*Plus.
Thx, DonatI moved this question to: Forum Home » Java Enterprise & Remote Computing » Enterprise JavaBeans
Donat -
Toplink JPA and handle to a sequence
Hi All,
I am trying to figure out a way to get a handle to an Oracle sequence and use it from the java application i.e. run operations like currval/nextval.
The reason I need this flexibility is to refer 2 sequences from the java app and apply it on a single table. Currently the table i am trying to insert already has a sequence which is a primary key generator. We do refer it in our JPA annotations and this works fine.
But there was a need where another column (not part of Primary key) also needs its values from a different sequence.
When we try to refer it from Toplink JPA it does not allow and errors stating cannot have 2 sequences mapping for a single table entity.
Let me know your thoughts.
ThanksYou could use a native SQL query to get the nextval or curval from the Sequence.
TopLink/EclipseLink should support an API for this, or allow multiple sequences per object, please vote for these bugs,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=267701
https://bugs.eclipse.org/bugs/show_bug.cgi?id=320456
James : http://www.eclipselink.org -
Let me just say that I posted a bug report for this here:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=3937
But I'm also posting the info here, so that people who search on this forum may get some help:
TopLink (both Essentials and 11g) has a problem with flushing entities
containing a self-reference relationship. When flushing, the following exception
occurs:
Exception [TOPLINK-7251] (Oracle TopLink Essentials - 2.1 (Build b14-fcs
(12/17/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: The attribute [id] of class [test.jpa.entities.Person] is
mapped to a primary key column in the database. Updates are not allowed.
No manual updates have been made to ANY primary key.
What I'm doing is:
1. I instantiate a new entity.
2. I start a transaction
3. I persist the new entity.
4. I read an existing entity from the DB.
5. I let the existing entity point to the new entity via the self-reference
relationship.
6. I flush the persistence context.
7. I issue commit(), and the exception occurs. (I have provided the stack traces for various versions of TopLink below.)
This is a clear bug.
Here are some additional observations:
1. Reproduced on the following versions of TopLink:
1.1. Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))
1.2. Oracle TopLink Essentials - 2.1 (Build b14-fcs (12/17/2007))
1.3. Oracle TopLink - 11g Technology Preview 3 (11.1.1.0.0) (Build 071214)
2. Reproducible both on Java SE and Java EE. (I tested on Oracle Application Server)
3. Reproducible with and without class weaving
4. Reproducible regardless of whether the JPA annotations are on fields or on
methods
5. Reproducible regardless of whether "cascade={CascadeType.PERSIST}" is used or
not.
6. Reproducible regardless of the fetch type of the self-reference relationship
(EAGER or LAZY).
Also:
1. Without flushing, the bug doesn't occur. That is, if I commit without
flushing, it works.
2. Without setting the self-reference relationship, the bug doesn't occur.
This is an issue that appears when using BOTH self-reference relationship AND
flushing.
Best regards,
Bisser
The message was edited by bisser:
Added info that the exception occurs "when I issue commit()" on step 7.I'm extremely surprised that you couldn't reproduce the error. It's reproduced each time when I run the Test Scenario that I described above.
You could download a sample Eclipse project that reproduces the error from here: https://glassfish.dev.java.net/issues/show_bug.cgi?id=3937
For the log below I used TopLink, version: Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007)).
Could you, please, tell me what version you use and I will try the Test Case on it.
Here's the FINEST log:
[TopLink Finest]: 2008.01.09 07:35:58.094--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--property=toplink.weaving; value=false
[TopLink Finest]: 2008.01.09 07:35:59.312--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--property=toplink.orm.throw.exceptions; default value=true
[TopLink Finer]: 2008.01.09 07:35:59.312--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--Searching for default mapping file in file:/D:/dev/bull/jpa_pk_bug/bin/
[TopLink Config]: 2008.01.09 07:35:59.547--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--The alias name for the entity class [class test.jpa.entities.Person] is being defaulted to: Person.
[TopLink Config]: 2008.01.09 07:35:59.594--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--The column name for element [private java.lang.Long test.jpa.entities.Person.id] is being defaulted to: ID.
[TopLink Config]: 2008.01.09 07:35:59.609--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--The column name for element [private java.lang.String test.jpa.entities.Person.name] is being defaulted to: NAME.
[TopLink Config]: 2008.01.09 07:35:59.641--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--The target entity (reference) class for the many to one mapping element [test.jpa.entities.Person test.jpa.entities.Person.mgr] is being defaulted to: class test.jpa.entities.Person.
[TopLink Config]: 2008.01.09 07:35:59.703--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--The primary key column name for the mapping element [test.jpa.entities.Person test.jpa.entities.Person.mgr] is being defaulted to: ID.
[TopLink Finest]: 2008.01.09 07:35:59.703--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--end predeploying Persistence Unit Test; state Predeployed; factoryCount 0
[TopLink Finer]: 2008.01.09 07:35:59.703--Thread(Thread[Main Thread,5,main])--cmp_init_transformer_is_null
[TopLink Finest]: 2008.01.09 07:35:59.703--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--begin predeploying Persistence Unit Test; state Predeployed; factoryCount 0
[TopLink Finest]: 2008.01.09 07:35:59.703--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--end predeploying Persistence Unit Test; state Predeployed; factoryCount 1
[TopLink Finest]: 2008.01.09 07:35:59.719--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--begin deploying Persistence Unit Test; state Predeployed; factoryCount 1
[TopLink Finest]: 2008.01.09 07:35:59.734--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--property=toplink.logging.level; value=FINEST; translated value=FINEST
[TopLink Finest]: 2008.01.09 07:35:59.734--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--property=toplink.logging.level; value=FINEST; translated value=FINEST
[TopLink Finest]: 2008.01.09 07:35:59.750--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--property=toplink.jdbc.user; value=rms
[TopLink Finest]: 2008.01.09 07:35:59.750--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--property=toplink.jdbc.password; value=xxxxxx
[TopLink Finest]: 2008.01.09 07:36:00.766--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--property=toplink.target-database; value=Oracle; translated value=oracle.toplink.essentials.platform.database.oracle.OraclePlatform
[TopLink Finest]: 2008.01.09 07:36:00.781--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--property=toplink.jdbc.driver; value=oracle.jdbc.OracleDriver
[TopLink Finest]: 2008.01.09 07:36:00.781--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--property=toplink.jdbc.url; value=jdbc:oracle:thin:@//10.20.6.126:1521/region2
[TopLink Info]: 2008.01.09 07:36:00.797--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--TopLink, version: Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))
[TopLink Config]: 2008.01.09 07:36:00.812--ServerSession(1968077)--Connection(5182312)--Thread(Thread[Main Thread,5,main])--connecting(DatabaseLogin(
platform=>OraclePlatform
user name=> "rms"
datasource URL=> "jdbc:oracle:thin:@//10.20.6.126:1521/region2"
[TopLink Config]: 2008.01.09 07:36:01.797--ServerSession(1968077)--Connection(4252099)--Thread(Thread[Main Thread,5,main])--Connected: jdbc:oracle:thin:@//10.20.6.126:1521/region2
User: RMS
Database: Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Driver: Oracle JDBC driver Version: 10.2.0.1.0
[TopLink Config]: 2008.01.09 07:36:01.797--ServerSession(1968077)--Connection(5744890)--Thread(Thread[Main Thread,5,main])--connecting(DatabaseLogin(
platform=>OraclePlatform
user name=> "rms"
datasource URL=> "jdbc:oracle:thin:@//10.20.6.126:1521/region2"
[TopLink Config]: 2008.01.09 07:36:01.875--ServerSession(1968077)--Connection(5747801)--Thread(Thread[Main Thread,5,main])--Connected: jdbc:oracle:thin:@//10.20.6.126:1521/region2
User: RMS
Database: Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Driver: Oracle JDBC driver Version: 10.2.0.1.0
[TopLink Config]: 2008.01.09 07:36:01.891--ServerSession(1968077)--Connection(5760373)--Thread(Thread[Main Thread,5,main])--connecting(DatabaseLogin(
platform=>OraclePlatform
user name=> "rms"
datasource URL=> "jdbc:oracle:thin:@//10.20.6.126:1521/region2"
[TopLink Config]: 2008.01.09 07:36:01.969--ServerSession(1968077)--Connection(5763284)--Thread(Thread[Main Thread,5,main])--Connected: jdbc:oracle:thin:@//10.20.6.126:1521/region2
User: RMS
Database: Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Driver: Oracle JDBC driver Version: 10.2.0.1.0
[TopLink Config]: 2008.01.09 07:36:01.969--ServerSession(1968077)--Connection(5497095)--Thread(Thread[Main Thread,5,main])--connecting(DatabaseLogin(
platform=>OraclePlatform
user name=> "rms"
datasource URL=> "jdbc:oracle:thin:@//10.20.6.126:1521/region2"
[TopLink Config]: 2008.01.09 07:36:02.047--ServerSession(1968077)--Connection(5500006)--Thread(Thread[Main Thread,5,main])--Connected: jdbc:oracle:thin:@//10.20.6.126:1521/region2
User: RMS
Database: Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Driver: Oracle JDBC driver Version: 10.2.0.1.0
[TopLink Config]: 2008.01.09 07:36:02.047--ServerSession(1968077)--Connection(5512041)--Thread(Thread[Main Thread,5,main])--connecting(DatabaseLogin(
platform=>OraclePlatform
user name=> "rms"
datasource URL=> "jdbc:oracle:thin:@//10.20.6.126:1521/region2"
[TopLink Config]: 2008.01.09 07:36:02.125--ServerSession(1968077)--Connection(5514977)--Thread(Thread[Main Thread,5,main])--Connected: jdbc:oracle:thin:@//10.20.6.126:1521/region2
User: RMS
Database: Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Driver: Oracle JDBC driver Version: 10.2.0.1.0
[TopLink Config]: 2008.01.09 07:36:02.125--ServerSession(1968077)--Connection(5527528)--Thread(Thread[Main Thread,5,main])--connecting(DatabaseLogin(
platform=>OraclePlatform
user name=> "rms"
datasource URL=> "jdbc:oracle:thin:@//10.20.6.126:1521/region2"
[TopLink Config]: 2008.01.09 07:36:02.203--ServerSession(1968077)--Connection(5530440)--Thread(Thread[Main Thread,5,main])--Connected: jdbc:oracle:thin:@//10.20.6.126:1521/region2
User: RMS
Database: Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Driver: Oracle JDBC driver Version: 10.2.0.1.0
[TopLink Config]: 2008.01.09 07:36:02.203--ServerSession(1968077)--Connection(5542993)--Thread(Thread[Main Thread,5,main])--connecting(DatabaseLogin(
platform=>OraclePlatform
user name=> "rms"
datasource URL=> "jdbc:oracle:thin:@//10.20.6.126:1521/region2"
[TopLink Config]: 2008.01.09 07:36:02.281--ServerSession(1968077)--Connection(5545904)--Thread(Thread[Main Thread,5,main])--Connected: jdbc:oracle:thin:@//10.20.6.126:1521/region2
User: RMS
Database: Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Driver: Oracle JDBC driver Version: 10.2.0.1.0
[TopLink Finest]: 2008.01.09 07:36:02.312--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--sequencing connected, state is Preallocation_NoTransaction_State
[TopLink Info]: 2008.01.09 07:36:02.484--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--file:/D:/dev/bull/jpa_pk_bug/bin/-Test login successful
[TopLink Finest]: 2008.01.09 07:36:02.484--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--end deploying Persistence Unit Test; state Deployed; factoryCount 1
[TopLink Finer]: 2008.01.09 07:36:02.516--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--client acquired
[TopLink Finest]: 2008.01.09 07:36:02.531--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--Execute query DoesExistQuery()
[TopLink Finest]: 2008.01.09 07:36:02.547--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--PERSIST operation called on: test.jpa.entities.Person@563c8c.
[TopLink Finest]: 2008.01.09 07:36:02.562--ClientSession(5666151)--Thread(Thread[Main Thread,5,main])--Execute query ValueReadQuery()
[TopLink Fine]: 2008.01.09 07:36:02.594--ServerSession(1968077)--Connection(5747801)--Thread(Thread[Main Thread,5,main])--SELECT PERSONS_ID_SEQ.NEXTVAL FROM DUAL
[TopLink Finest]: 2008.01.09 07:36:03.297--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--sequencing preallocation for PERSONS_ID_SEQ: objects: 1 , first: 5, last: 5
[TopLink Finest]: 2008.01.09 07:36:03.312--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--assign sequence to the object (5 -> test.jpa.entities.Person@563c8c)
[TopLink Finest]: 2008.01.09 07:36:03.328--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--Execute query ReadObjectQuery(test.jpa.entities.Person)
[TopLink Fine]: 2008.01.09 07:36:03.438--ServerSession(1968077)--Connection(4252099)--Thread(Thread[Main Thread,5,main])--SELECT ID, NAME, MGR_ID FROM Persons WHERE (ID = ?)
bind => [1]
[TopLink Finest]: 2008.01.09 07:36:03.531--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--Register the existing object test.jpa.entities.Person@3a4484
[TopLink Finer]: 2008.01.09 07:36:03.625--ClientSession(5666151)--Connection(5763284)--Thread(Thread[Main Thread,5,main])--begin transaction
[TopLink Finest]: 2008.01.09 07:36:03.625--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--Execute query UpdateObjectQuery(test.jpa.entities.Person@3a57fa)
[TopLink Finest]: 2008.01.09 07:36:03.641--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--Execute query WriteObjectQuery(test.jpa.entities.Person@563c8c)
[TopLink Fine]: 2008.01.09 07:36:03.656--ClientSession(5666151)--Connection(5763284)--Thread(Thread[Main Thread,5,main])--INSERT INTO Persons (ID, NAME, MGR_ID) VALUES (?, ?, ?)
bind => [5, Boss, null]
[TopLink Fine]: 2008.01.09 07:36:03.688--ClientSession(5666151)--Connection(5763284)--Thread(Thread[Main Thread,5,main])--UPDATE Persons SET MGR_ID = ? WHERE (ID = ?)
bind => [5, 1]
[TopLink Finer]: 2008.01.09 07:36:03.703--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--begin unit of work commit
[TopLink Finest]: 2008.01.09 07:36:03.703--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--Execute query UpdateObjectQuery(test.jpa.entities.Person@563c8c)
[TopLink Warning]: 2008.01.09 07:36:03.812--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--Local Exception Stack:
Exception [TOPLINK-7251] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: The attribute [id] of class [test.jpa.entities.Person] is mapped to a primary key column in the database. Updates are not allowed.
at oracle.toplink.essentials.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2222)
at oracle.toplink.essentials.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRowWithChangeRecord(AbstractDirectMapping.java:750)
at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRowForUpdateWithChangeSet(ObjectBuilder.java:948)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1263)
at oracle.toplink.essentials.queryframework.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:91)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:390)
at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:109)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:555)
at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:138)
at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:110)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
at oracle.toplink.essentials.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:309)
at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:195)
at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2657)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1044)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:403)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1126)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:107)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:856)
at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:102)
at oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:60)
at test.jpa.TestPkBug.runTest(TestPkBug.java:53)
at test.jpa.TestPkBug.main(TestPkBug.java:95)
[TopLink Finer]: 2008.01.09 07:36:03.828--ClientSession(5666151)--Connection(5763284)--Thread(Thread[Main Thread,5,main])--rollback transaction
[TopLink Finer]: 2008.01.09 07:36:03.844--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--release unit of work
[TopLink Finer]: 2008.01.09 07:36:03.844--UnitOfWork(5663897)--Thread(Thread[Main Thread,5,main])--initialize identitymaps
[TopLink Finer]: 2008.01.09 07:36:03.844--ClientSession(5666151)--Thread(Thread[Main Thread,5,main])--client released
[TopLink Finest]: 2008.01.09 07:36:03.844--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--begin undeploying Persistence Unit Test; state Deployed; factoryCount 1
[TopLink Finest]: 2008.01.09 07:36:03.844--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--sequencing disconnected
[TopLink Config]: 2008.01.09 07:36:03.844--ServerSession(1968077)--Connection(4252099)--Thread(Thread[Main Thread,5,main])--disconnect
[TopLink Finer]: 2008.01.09 07:36:03.859--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--initialize identitymaps
[TopLink Info]: 2008.01.09 07:36:03.859--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--file:/D:/dev/bull/jpa_pk_bug/bin/-Test logout successful
[TopLink Config]: 2008.01.09 07:36:03.859--ServerSession(1968077)--Connection(5747801)--Thread(Thread[Main Thread,5,main])--disconnect
[TopLink Config]: 2008.01.09 07:36:03.859--ServerSession(1968077)--Connection(5182312)--Thread(Thread[Main Thread,5,main])--disconnect
[TopLink Config]: 2008.01.09 07:36:03.859--ServerSession(1968077)--Connection(5500006)--Thread(Thread[Main Thread,5,main])--disconnect
[TopLink Config]: 2008.01.09 07:36:03.875--ServerSession(1968077)--Connection(5514977)--Thread(Thread[Main Thread,5,main])--disconnect
[TopLink Config]: 2008.01.09 07:36:03.875--ServerSession(1968077)--Connection(5530440)--Thread(Thread[Main Thread,5,main])--disconnect
[TopLink Config]: 2008.01.09 07:36:03.875--ServerSession(1968077)--Connection(5545904)--Thread(Thread[Main Thread,5,main])--disconnect
[TopLink Config]: 2008.01.09 07:36:03.891--ServerSession(1968077)--Connection(5763284)--Thread(Thread[Main Thread,5,main])--disconnect
[TopLink Finest]: 2008.01.09 07:36:03.891--ServerSession(1968077)--Thread(Thread[Main Thread,5,main])--end undeploying Persistence Unit Test; state Undeployed; factoryCount 0
Exception in thread "Main Thread" javax.persistence.RollbackException: Exception [TOPLINK-7251] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: The attribute [id] of class [test.jpa.entities.Person] is mapped to a primary key column in the database. Updates are not allowed.
at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:120)
at oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:60)
at test.jpa.TestPkBug.runTest(TestPkBug.java:53)
at test.jpa.TestPkBug.main(TestPkBug.java:95)
Caused by: Exception [TOPLINK-7251] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: The attribute [id] of class [test.jpa.entities.Person] is mapped to a primary key column in the database. Updates are not allowed.
at oracle.toplink.essentials.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2222)
at oracle.toplink.essentials.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRowWithChangeRecord(AbstractDirectMapping.java:750)
at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRowForUpdateWithChangeSet(ObjectBuilder.java:948)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1263)
at oracle.toplink.essentials.queryframework.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:91)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:390)
at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:109)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:555)
at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:138)
at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:110)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
at oracle.toplink.essentials.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:309)
at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:195)
at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2657)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1044)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:403)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1126)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:107)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:856)
at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:102)
... 3 moreEDIT: Are you using the EXACT Test Case as I have described it in the previous posts? It's important that you commit(), and not rollback(), the transaction after the flush.
EDIT: Updated the log because I found out that I had made a small change to the original Test Case while I was trying to find a workaround. The current log is produced by the EXACT Test Case I described in my previous posts.
Message was edited by:
bisser -
JPA/Toplink changes the query logic
Hi,
Iam currently using JPA with Toplink implementation , i guess that toplink has its own way of optimizing the provided JPA query ; on another words , toplink sometimes changes the way you are using joins and exists statement to what looks optimized , but unfor. this caused me troubles tracking a query that should work on a certain way but its not cause the generated query by Toplink ( can be captured on the log ) does not represent the same logic , is this a known issue or do i have to write my JPA query on a way on which can be translated correctly by toplink , i know i should provide the query it self , but the model structure is too complex.
Thanks in advanceHello,
JPQL does not directly translate to SQL, so there might be some differences in what you may be expecting due to JPA requirements on the results that are returned. If there is a problem with specific queries, please let us know and file a bug if it is not behaving the way it should. A workaround would be to use a native SQL query directly.
Best Regards,
Chris
Maybe you are looking for
-
I have multiple copies of phantom books in ibooks on my ipad. By phantom I mean, that they appear to be partially downloaded. They will not resume downloading or allow deletion. None of these books are on my mac, they have been deleted. These are boo
-
Storing an object in Session, is that a good practice
Hi, In application, I have a class that is very much important class, that is very much important for every backing bean class. So I am initializing at the time of login and keeping that object in the session and every time when ever the application
-
Divide file contents and read from threads
I am reading a file which contains doubles... I can do this with 1 thread. Now I want to use 2 threads and make each thread read half of that file.. How do I make file to half .. If I take the length and divide by two wont it destort the doubles? pub
-
Where did my gestures go?
I recently took my 2008 15in 2.2/2.4 MBP to Apple to have the logic board replace because the screen was not working. I opted for the "fix everything plan" for around $310. When I received my MBP back from Apple, they had replaced not only the logi
-
Newbie: Jdev's intelisense not working for HOUR_OF_DAY
I'm using Jdev preview 4. Suppose I have below code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html;charset=windows-1252"%> <html> <head> <meta http-equiv="Conten