Hi Andrey,
On Jan 7, 2008, at 5:43 PM, <hmai..otmail.ru> <hmail@hotmail.ru> wrote:
> 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?
If it is a bug, it is a bug in the Oracle driver... I vaguely recall
the driver supplying very little information on the specific nature of
a NUMERIC type. Anyways, a place to fix it locally is either the
types.xml file for Oracle adapter:
Or the OracleAdapter.buildAttribute(..) method:
> 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?)
Current naming strategy reflects out mindset 7 years ago when we
started Cayenne. Actually my current preference is also to drop "to"
prefix and "Array" suffix.. But anyways ... currently there's no
pluggable naming strategy so you can either check the DbLoader class
that drives reverse-engineering and make local modifications:
Or maybe just use Perl on a generated XML file to batch-rename all
relationships to your liking (this maybe a good approach for #1 as
well - probably take you less time than recompiling Cayenne).
> 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 data.
> 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?).
You can simply delete ObjRelationships from Dictionary that you don't
need. (Leave the underlying DbRelationships unchanged... also in
Cayenne 3.0 bi-directional DbRelationships are also optional and can
be deleted if desired).
> 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()' methods).
> So the question is: will my copy support such lazy fetching and how
> can i create such copy?
On the server-side the solution would've been a nested DataContext...
Since nested contexts are not yet supported on the client (we should
really fix that), your other option is a "peer" context... So you'd
simply use context1 for display and context2 for editing, both working
off of the same connection channel.
Hope this helps,
Andrus
P.S. As I got your message via the moderation queue, I assume you are
not subscribed to the list, so be aware that some other replies may go
directly to the list, without a "cc:" to your address.
This archive was generated by hypermail 2.0.0 : Mon Jan 07 2008 - 11:30:51 EST