cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Several questions about Cayenne
Date Mon, 07 Jan 2008 15:43:29 GMT

I'm considering using Cayenne in my 3-tier desktop applications. I studied Cayenne a bit and
liked it, especially the ROP feature. But i've got some questions about things that may be
important in my app (actially i'm comparing Cayenne to Hibernate and seem to find Cayenne
better :) )

1. I'm currently using two types of database - Oracle and Postgresql. I'm currently using
reverse engineering because I already have a database full with data. And i have a lot of
tables with PK and FK identifiers of types 'NUMBER' in Oracle and 'int8' in PGSQL. In postresql
everything works just fine, and int8 is mapped to java.lang.Long object. But in Oracle, Cayenne
Modeler mappes it to Integer, so i get exceptions when trying to fetch data (my identifiers
values are greater than Integer.MAX_VALUE). So the question is: 'Where is described automatical
mapping between special database types and java types?'. If I have to change it directly myself
in the code, please say where exactly (in what class) it is. Or it can be set somewhere, or
it is a bug?

2. About property naming strategy.
Suppose i have two db tables (and so, classes): Person and Address, and Person is linked many-to-one
to Address (so there is 'addressid' column in Person table). When i generate classes using
Cayenne modeler, I get method like this in _Person class:
public Address getToAddress() { ... }
I find the method rather ugly because-of the 'to' prefix, but there is more.
If i have two links to address, like 'workaddressid' and 'home addressid' i get such methods:
public Address getToAddress1() { ... }
public Address getToAddress2() { ... }
Which is much more ugly and ununderstandable. I would like to get methods:
public Address getAddress() { ... } - in the first case.

public Address getHomeaddress() { ... }
public Address getWorkaddress() { ... } - in the second case.
Actually Hibernate does right this.

So how can i change the name strategy (again, if you don't support this maybe i can do it
directly in the code?)

3. Now i have a table called 'Dictionary' which is nothing more than storing different data,
withod 'outgoing' links to other tables. But there are a lot of 'incoming' links from other
tables, because a lot of them would rather have a link to dic, than to duplicate dictionary
With Cayenne everything is mapped just fine in classes, but when i made direct SelectQuery
from dictionary (well, i need some UI to modify dictionary data), i found it works too long
because of lots of dependencies (of course, i'm using lazy fetching, so i don't load exact
data from depend tables). I think this time is being spent on some object (collections) creation
or something. 
The same thing i found in Hibernate, but there i managed to turn off 'one side' of the link
by removing the link description from XML mapping of Dictionary. How can i do it in Cayenne?
(if i was not clear, i need access from other tables to (-one) Dictionary, but i can sacrify
access from Dictionary to (-to many collections) other tables if it increases direct select
from dictionary speed. (Or maybe i just need to use something other than SelectQuery?).

4. I wanna use ROP, so i create 'client' classes and establish connection to CWS. 
I have a GUI table which shows some data from database (the source of that data is actually
Cayenne Client classes). Now i want this data to be edited in some other 'card' form. So i
need to create a copy from object, which represents some line in GUI which will be source
for GUI components in the card (such as textfield). I need a copy because i don't want data
in table be changed before user pressed 'save' button in 'card' form. But in my card i might
need some data which is not yet fetched from database (which can be accessed via 'getToXXX()'
So the question is: will my copy support such lazy fetching and how can i create such copy?

Thanks for your answers, 
Andrey Razumovsky,
Saint-Petersburg, Russia)

View raw message