Hi,

im just trying the first steps to cache java projection, however it wont
work. what is wrong with following code ?

Eclipse says problems:

Severity Description Resource In Folder Location Creation Time
2 The method Database() is undefined for the type WWdata WWdata.java
whiskyworld-v6/src/whiskyworld line 22 20. Mai 2004 14:58:22
2 The constructor TestKlasse1(String) is undefined WWdata.java
whiskyworld-v6/src/whiskyworld line 23 20. Mai 2004 14:58:22
2 The method setGewicht(Double) in the type TestKlasse1 is not applicable
for the arguments (String) WWdata.java whiskyworld-v6/src/whiskyworld line
25 20. Mai 2004 14:58:22
2 The method setPreis(BigDecimal) in the type TestKlasse1 is not applicable
for the arguments (String) WWdata.java whiskyworld-v6/src/whiskyworld line
26 20. Mai 2004 14:58:22

funnywise i followed the example in the Cache book from Springer - as stated
on page 318:

String strCon = "jdbc:Cache://127.0.0.1:1972/WHISKYWORLD";
Database db = Database().getDatabase(strCon,"wwuser","wwuser");

im quite unsure whats wrong - ive added the CACHE.JAR file as well as the
TestKlasse1.java -projection done by Cache Studio projection.

Anyone a clue ?

greetings

Korbinian

-> File WWdata.java

/*
* Created on 20.05.2004

*

* TODO To change the template for this generated file go to

* Window - Preferences - Java - Code Generation - Code and Comments

*/

package whiskyworld;

import com.intersys.objects.Database;



/**

* @author Korbinian

*

* TODO To change the template for this generated type comment go to

* Window - Preferences - Java - Code Generation - Code and Comments

*/

public class WWdata {


public void setData()

{

String strCon = "jdbc:Cache://127.0.0.1:1972/WHISKYWORLD";

Database db = Database().getDatabase(strCon,"wwuser","wwuser");

TestKlasse1 var = new TestKlasse1("db");

var.setBestnr("MA-1200");

var.setGewicht("5.79");

var.setPreis("99.96");

var.save();

System.out.println("artikel gesetzt");


}

}



File TestKlasse1.java (made by Cache Studio Projection)

package whiskyworld;

import com.intersys.cache.*;

import com.intersys.objects.*;

import com.intersys.objects.reflect.*;

import com.intersys.classes.*;

import java.sql.Date;

import java.math.BigDecimal;

import java.sql.Time;

import java.sql.Timestamp;



public class TestKlasse1 extends Persistent {

private static String CACHE_CLASS_NAME = "whiskyworld.TestKlasse1";

/**

NB: DO NOT USE IN APPLICATION!

Use <code>TestKlasse1._open</code> instead.

<p>

Used to construct a Java object, corresponding to existing object

in Cache database.

@see #_open(com.intersys.objects.Database, com.intersys.objects.Oid)

@see #_open(com.intersys.objects.Database, com.intersys.objects.Id)

*/

public TestKlasse1 (CacheObject ref) throws CacheException {

super (ref);

}

/**

Creates a new instance of object "<CacheClassName>" in Cache

database and corresponding object of class

<code>TestKlasse1</code>.

@param db <code>Database</code> object used for connection with

Cache database.

@throws CacheException in case of error.

@see #_open(com.intersys.objects.Database, com.intersys.objects.Oid)

@see #_open(com.intersys.objects.Database, com.intersys.objects.Id)

*/

public TestKlasse1 (Database db) throws CacheException {

super (((SysDatabase)db).newCacheObject (CACHE_CLASS_NAME));

}

/**

Runs method <code> %OpenId </code> in Cache to open an object

from Cache database and creates corresponding object of class

<code>TestKlasse1</code>.

@return <code> RegisteredObject </code>, corresponding to opened

object. This object may be of <code>TestKlasse1</code> or of

any of it's subclasses. Cast to <code>TestKlasse1</code> is

garanteed to pass without <code>ClassCastException</code> exception.

@param db <code>Database</code> object used for connection with

Cache database.

@param id ID as specified in Cache represented as

<code>Id</code>.

@throws CacheException in case of error.

@see java.lang.ClassCastException

@see #_open(com.intersys.objects.Database, com.intersys.objects.Oid)

@see #TestKlasse1

*/

public static RegisteredObject _open (Database db, Id id) throws
CacheException {

CacheObject cobj = (((SysDatabase)db).openCacheObject(CACHE_CLASS_NAME,
id.toString()));

return (RegisteredObject)(cobj.newJavaInstance());

}

public static RegisteredObject _open (Database db, Id id, int concurrency)
throws CacheException {

CacheObject cobj = (((SysDatabase)db).openCacheObject(CACHE_CLASS_NAME,
id.toString(), concurrency));

return (RegisteredObject)(cobj.newJavaInstance());

}

/**

Runs method <code> %Open </code> in Cache to open an object

from Cache database and creates corresponding object of class

<code>TestKlasse1</code>.

@return <code> RegisteredObject </code>, corresponding to opened

object. This object may be of <code>TestKlasse1</code> or of

any of it's subclasses. Cast to <code>TestKlasse1</code> is

garanteed to pass without <code>ClassCastException</code> exception.

@param db <code>Database</code> object used for connection with

Cache database.

@param oid Object ID as specified in Cache. represented as

<code>Oid</code>.



@throws CacheException in case of error.

@see java.lang.ClassCastException

@see #_open(com.intersys.objects.Database, com.intersys.objects.Id)

@see #TestKlasse1(com.intersys.objects.Database)

*/

public static RegisteredObject _open (Database db, Oid oid) throws
CacheException {

CacheObject cobj = (((SysDatabase)db).openCacheObject(CACHE_CLASS_NAME,
oid.getData()));

return (RegisteredObject)(cobj.newJavaInstance());

}

public static RegisteredObject _open (Database db, Oid oid, int concurrency)
throws CacheException {

CacheObject cobj = (((SysDatabase)db).openCacheObject(CACHE_CLASS_NAME,
oid.getData(), concurrency));

return (RegisteredObject)(cobj.newJavaInstance());

}

public static void delete (Database db, Id id) throws CacheException {

((SysDatabase)db).deleteObject(CACHE_CLASS_NAME, id);

}

public static void delete (Database db, Id id, int concurrency) throws
CacheException {

((SysDatabase)db).deleteObject(CACHE_CLASS_NAME, id, concurrency);

}

public static void _deleteId (Database db, Id id) throws CacheException {

delete(db, id);

}

public static void _deleteId (Database db, Id id, int concurrency) throws
CacheException {

delete(db, id, concurrency);

}

public static boolean exists (Database db, Id id) throws CacheException {

return ((SysDatabase)db).existsObject(CACHE_CLASS_NAME, id);

}

public static Boolean _existsId (Database db, Id id) throws CacheException {

return new Boolean(exists(db, id));

}

/**

Returns class name of the class TestKlasse1 as it is in

Cache Database. Note, that this is a static method, so no

object specific information can be returned. Use

<code>getCacheClass().geName()</code> to get the class name

for specific object.

@return Cache class name as a <code>String</code>

@see #getCacheClass()

@see com.intersys.objects.reflect.CacheClass#getName()

*/

public static String getCacheClassName( ) {

return CACHE_CLASS_NAME;

}

/**

Allows access metadata information about type of this object

in Cache database. Also can be used for dynamic binding (accessing

properties and calling methods without particular class known).

@return <code>CacheClass</code> object for this object type.

*/

public CacheClass getCacheClass( ) throws CacheException {

return mInternal.getCacheClass();

}

/**

Verifies that all fields from Cache class are exposed with

accessor methods in Java class and that values for indexes in

zObjVal are the same as in Cache. It does not return anything

but it thorws an exception in case of inconsistency.

<p> Please note, that if any field is not exposed that i

critical error. But if there is any inconsistncy in zObjVal

indexes this is fatal and class can not work correctly and must

be regenrated.

@param db Databse used for connection. Note that if you are

using multiple databases the class can be consistent with one

and inconsistent with another.

@throws InvalidClassException if any inconsistency is found.

@throws CacheException if any error occured during

verification, e.g. communication error with Databse.

@see com.intersys.objects.InvalidPropertyException

*/

public static void checkAllFieldsValid(Database db ) throws CacheException {

checkAllFieldsValid(db, CACHE_CLASS_NAME, TestKlasse1.class);

}

public static boolean exists (Database db, Oid oid) throws CacheException {

return exists (db, oid, CACHE_CLASS_NAME);

}

/**

Verifies that all fields from Cache class are exposed with

accessor methods in Java class and that values for indexes in

zObjVal are the same as in Cache. It does not return anything

but it thorws an exception in case of inconsistency.

<p> Please note, that if any field is not exposed that i

critical error. But if there is any inconsistncy in zObjVal

indexes this is fatal and class can not work correctly and must

be regenrated.

@param db Databse used for connection. Note that if you are

using multiple databases the class can be consistent with one

and inconsistent with another.

@throws InvalidClassException if any inconsistency is found.

@throws CacheException if any error occured during

verification, e.g. communication error with Databse.

@see com.intersys.objects.InvalidPropertyException

*/

public static void checkAllMethods(Database db ) throws CacheException {

checkAllMethods(db, CACHE_CLASS_NAME, TestKlasse1.class);

}

private static int ii_Bestnr = 3;

private static int jj_Bestnr = 0;

private static int kk_Bestnr = 3;

/**

Verifies that indexes for property <code>Bestnr</code> in

zObjVal are the same as in Cache. It does not return anything

but it thorws an exception in case of inconsistency.

<p> Please note, that if there is any inconsistncy in zObjVal

indexes this is fatal and class can not work correctly and must

be regenrated.

@param db Databse used for connection. Note that if you are

using multiple databases the class can be consistent with one

and inconsistent with another.

@throws InvalidClassException if any inconsistency is found.

@throws CacheException if any error occured during

verification, e.g. communication error with Databse.

@see #checkAllFieldsValid

*/

public static void checkBestnrValid (Database db) throws CacheException {

checkZobjValid(db, CACHE_CLASS_NAME, "Bestnr",ii_Bestnr, jj_Bestnr,
kk_Bestnr);

}

/**

Returns value of property <code>Bestnr</code>

@return current value of <code>Bestnr</code> represented as

<code><PropType></code>

@throws CacheException if any error occured during value retrieval.

*/

public java.lang.String getBestnr() throws CacheException {

Dataholder dh = mInternal.getProperty(ii_Bestnr,

jj_Bestnr,

Database.RET_PRIM,

"Bestnr");

return dh.getString();

}

/**

Returns value of property <code>Bestnr</code>

@return current value of <code>Bestnr</code> represented as

<code><PropType></code>

@throws CacheException if any error occured during value retrieval.

*/

public void setBestnr(java.lang.String value) throws CacheException {

Dataholder dh = new Dataholder (value);

mInternal.setProperty(ii_Bestnr, jj_Bestnr,kk_Bestnr, Database.RET_PRIM,
"Bestnr", dh);

return;

}

private static int ii_Gewicht = 4;

private static int jj_Gewicht = 0;

private static int kk_Gewicht = 4;

/**

Verifies that indexes for property <code>Gewicht</code> in

zObjVal are the same as in Cache. It does not return anything

but it thorws an exception in case of inconsistency.

<p> Please note, that if there is any inconsistncy in zObjVal

indexes this is fatal and class can not work correctly and must

be regenrated.

@param db Databse used for connection. Note that if you are

using multiple databases the class can be consistent with one

and inconsistent with another.

@throws InvalidClassException if any inconsistency is found.

@throws CacheException if any error occured during

verification, e.g. communication error with Databse.

@see #checkAllFieldsValid

*/

public static void checkGewichtValid (Database db) throws CacheException {

checkZobjValid(db, CACHE_CLASS_NAME, "Gewicht",ii_Gewicht, jj_Gewicht,
kk_Gewicht);

}

/**

Returns value of property <code>Gewicht</code>

@return current value of <code>Gewicht</code> represented as

<code><PropType></code>

@throws CacheException if any error occured during value retrieval.

*/

public java.lang.Double getGewicht() throws CacheException {

Dataholder dh = mInternal.getProperty(ii_Gewicht,

jj_Gewicht,

Database.RET_PRIM,

"Gewicht");

return dh.getDouble();

}

/**

Returns value of property <code>Gewicht</code>

@return current value of <code>Gewicht</code> represented as

<code><PropType></code>

@throws CacheException if any error occured during value retrieval.

*/

public void setGewicht(java.lang.Double value) throws CacheException {

Dataholder dh = new Dataholder (value);

mInternal.setProperty(ii_Gewicht, jj_Gewicht,kk_Gewicht, Database.RET_PRIM,
"Gewicht", dh);

return;

}

private static int ii_Preis = 5;

private static int jj_Preis = 0;

private static int kk_Preis = 5;

/**

Verifies that indexes for property <code>Preis</code> in

zObjVal are the same as in Cache. It does not return anything

but it thorws an exception in case of inconsistency.

<p> Please note, that if there is any inconsistncy in zObjVal

indexes this is fatal and class can not work correctly and must

be regenrated.

@param db Databse used for connection. Note that if you are

using multiple databases the class can be consistent with one

and inconsistent with another.

@throws InvalidClassException if any inconsistency is found.

@throws CacheException if any error occured during

verification, e.g. communication error with Databse.

@see #checkAllFieldsValid

*/

public static void checkPreisValid (Database db) throws CacheException {

checkZobjValid(db, CACHE_CLASS_NAME, "Preis",ii_Preis, jj_Preis, kk_Preis);

}

/**

Returns value of property <code>Preis</code>

@return current value of <code>Preis</code> represented as

<code><PropType></code>

@throws CacheException if any error occured during value retrieval.

*/

public java.math.BigDecimal getPreis() throws CacheException {

Dataholder dh = mInternal.getProperty(ii_Preis,

jj_Preis,

Database.RET_PRIM,

"Preis");

return dh.getBigDecimal();

}

/**

Returns value of property <code>Preis</code>

@return current value of <code>Preis</code> represented as

<code><PropType></code>

@throws CacheException if any error occured during value retrieval.

*/

public void setPreis(java.math.BigDecimal value) throws CacheException {

Dataholder dh = new Dataholder (value);

mInternal.setProperty(ii_Preis, jj_Preis,kk_Preis, Database.RET_PRIM,
"Preis", dh);

return;

}

/**

Runs method OnPopulate in Cache

@throws CacheException if any error occured while running the method.

@see #OnPopulate()

*/

public void OnPopulate () throws CacheException {

Dataholder[] args = new Dataholder[0];

Dataholder
res=mInternal.runInstanceMethod("OnPopulate",args,Database.RET_PRIM);

getDatabase().parseStatus(res);

return;

}

/**

Runs method Populate in Cache

@param db represented as Database

@param count set to 10

@param verbose set to 0

@param DeferIndices set to 1

@param objects set to 0

@throws CacheException if any error occured while running the method.

@see
#Populate(Database,java.lang.Integer,java.lang.Integer,java.lang.Integer,com
.intersys.objects.IntegerHolder)

*/

public static java.lang.Integer Populate (Database db) throws CacheException
{

Dataholder[] args = new Dataholder[0];

int[] refs = new int[0];

Dataholder[]
res=db.runClassMethod(CACHE_CLASS_NAME,"Populate",refs,args,Database.RET_PRI
M);

return res[0].getInteger();

}

/**

Runs method Populate in Cache

@param db represented as Database

@param count represented as java.lang.Integer

@param verbose set to 0

@param DeferIndices set to 1

@param objects set to 0

@throws CacheException if any error occured while running the method.

@see
#Populate(Database,java.lang.Integer,java.lang.Integer,java.lang.Integer,com
.intersys.objects.IntegerHolder)

*/

public static java.lang.Integer Populate (Database db, java.lang.Integer
count) throws CacheException {

Dataholder[] args = new Dataholder[1];

int[] refs = new int[0];

args[0] = new Dataholder(count);

Dataholder[]
res=db.runClassMethod(CACHE_CLASS_NAME,"Populate",refs,args,Database.RET_PRI
M);

return res[0].getInteger();

}

/**

Runs method Populate in Cache

@param db represented as Database

@param count represented as java.lang.Integer

@param verbose represented as java.lang.Integer

@param DeferIndices set to 1

@param objects set to 0

@throws CacheException if any error occured while running the method.

@see
#Populate(Database,java.lang.Integer,java.lang.Integer,java.lang.Integer,com
.intersys.objects.IntegerHolder)

*/

public static java.lang.Integer Populate (Database db, java.lang.Integer
count, java.lang.Integer verbose) throws CacheException {

Dataholder[] args = new Dataholder[2];

int[] refs = new int[0];

args[0] = new Dataholder(count);

args[1] = new Dataholder(verbose);

Dataholder[]
res=db.runClassMethod(CACHE_CLASS_NAME,"Populate",refs,args,Database.RET_PRI
M);

return res[0].getInteger();

}

/**

Runs method Populate in Cache

@param db represented as Database

@param count represented as java.lang.Integer

@param verbose represented as java.lang.Integer

@param DeferIndices represented as java.lang.Integer

@param objects set to 0

@throws CacheException if any error occured while running the method.

@see
#Populate(Database,java.lang.Integer,java.lang.Integer,java.lang.Integer,com
.intersys.objects.IntegerHolder)

*/

public static java.lang.Integer Populate (Database db, java.lang.Integer
count, java.lang.Integer verbose, java.lang.Integer DeferIndices) throws
CacheException {

Dataholder[] args = new Dataholder[3];

int[] refs = new int[0];

args[0] = new Dataholder(count);

args[1] = new Dataholder(verbose);

args[2] = new Dataholder(DeferIndices);

Dataholder[]
res=db.runClassMethod(CACHE_CLASS_NAME,"Populate",refs,args,Database.RET_PRI
M);

return res[0].getInteger();

}

/**

Runs method Populate in Cache

@param db represented as Database

@param count represented as java.lang.Integer

@param verbose represented as java.lang.Integer

@param DeferIndices represented as java.lang.Integer

@param objects represented as com.intersys.objects.IntegerHolder

@throws CacheException if any error occured while running the method.

@see
#Populate(Database,java.lang.Integer,java.lang.Integer,java.lang.Integer,com
.intersys.objects.IntegerHolder)

*/

public static java.lang.Integer Populate (Database db, java.lang.Integer
count, java.lang.Integer verbose, java.lang.Integer DeferIndices,
com.intersys.objects.IntegerHolder objects) throws CacheException {

Dataholder[] args = new Dataholder[4];

int[] refs = new int[1];

args[0] = new Dataholder(count);

args[1] = new Dataholder(verbose);

args[2] = new Dataholder(DeferIndices);

args[3] = Dataholder.create (objects.value);

refs[0] = 4;

Dataholder[]
res=db.runClassMethod(CACHE_CLASS_NAME,"Populate",refs,args,Database.RET_PRI
M);

objects.set(res[1].getInteger());

return res[0].getInteger();

}

/**

Runs method PopulateSerial in Cache

@param db represented as Database

@throws CacheException if any error occured while running the method.

@see #PopulateSerial(Database)

*/

public static java.lang.String PopulateSerial (Database db) throws
CacheException {

Dataholder[] args = new Dataholder[0];

Dataholder
res=db.runClassMethod(CACHE_CLASS_NAME,"PopulateSerial",args,Database.RET_PR
IM);

return res.getString();

}

}



Reply via email to