Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ReadObjectQuery - Invalid query key

656067Nov 7 2008 — edited Nov 10 2008
Hello again :)
A have still stuck on TopLink :(
I created very simple example:

DB:
create table TESTIK
(
ID NUMBER not null,
NAZEV VARCHAR2(255),
VERSION NUMBER
)

I created new project in TopLink WorkBench, created new session.. I mean, there is no problem (but I'm not sure :) ) .
I created new Dynamic WebApplication in Eclipse, using Glassfish server and framework JSF...
My source:

This is my entity, represent table TESTIK
Testik.class:
package toplink.model.entity;
import java.io.Serializable;
public class Testik implements Serializable { // implements Serializable
private int id;
private String nazev;
private int version;

public Testik() {
}

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNazev() {
return nazev;
}
public void setNazev(String nazev) {
this.nazev = nazev;
}

public int getVersion() {
return version;
}

public void setVersion(int version) {
this.version = version;
}
}

This is for create session - i don't now, is it rights? :)
SessionSetting.class:
package toplink.services.settings;

import oracle.toplink.sessions.Project;
import oracle.toplink.threetier.Server;
import oracle.toplink.tools.workbench.XMLProjectReader;

public class SessionSetting extends oracle.toplink.platform.xml. jaxp.JAXPPlatform {
public SessionSetting() {
}
public Server getSession(){
System.setProperty("toplink.xml.platform", "oracle.toplink.platform.xml.jaxp.JAXPPlatform");
Project myProject = XMLProjectReader.read("c:/ecl_work/TopLink_Intro/src/META-INF/TopLink_Intro.xml", Thread.currentThread().getContextClassLoader());
Server serverSession = myProject.createServerSession();
return serverSession;
}
}

And if I want used some query:

public Testik findById(int id) {
SessionSetting ss = new SessionSetting();
Server session = ss.getSession();
Testik testik = (Testik) session.readObject(Testik.class, new ExpressionBuilder().get("id").equal(1));
return testik;
}

But this return Exception:
javax.servlet.ServletException: #{testikManagedBean.najdiTestik}: Exception [TOPLINK-6015] (Oracle TopLink - 11g (11.1.1.0.0) (Build 080909)): oracle.toplink.exceptions.QueryException
Exception Description: Invalid query key [id] in expression.
Query: ReadObjectQuery(toplink.model.entity.Testik)

Where testikManagedBean.najdiTestik call findById(int id) !

I tried used StoredProcedureCall, ReadObjectQuery, ValueReadQuery, ReadAllQuery and nothing works :(

Example:
public Collection<Testik> findAll(){
SessionSetting ss = new SessionSetting();
Server session = ss.getSession();
Collection<Testik> testiky = session.readAllObjects(Testik.class);
return testiky;
}

but in this example, it works a long time and return:
javax.servlet.ServletException: #{testikManagedBean.vsechnyTestiky}: Exception [TOPLINK-4002] (Oracle TopLink - 11g (11.1.1.0.0) (Build 080909)): oracle.toplink.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Exception input/output: The Network Adapter could not establish the connection
Error Code: 17002
Query: ReadAllQuery(toplink.model.entity.Testik)

I know what it means in this problem, but I do not know where is it, because in the workbench I can normally connect to the database... Is this problem in sessions or where?

Please, I tried some very simple example, how to use TopLink and Queries and i'm still stuck.. I'm newbie in toplink and I do not know your advice...
Please, could you help me with my problem?

Thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2008
Added on Nov 7 2008
3 comments
3,228 views