Hi Joose.

Joose Vettenranta Escribio :-)
> I checked that sample files I got and checked the website and googled
> like maniac.. And still not getting anywhere..
>
> Is it realy this difficult or have I just missed something? I have now
> tried about 30h to make this work but still no luck.
>
> Current status:
>
> - Getting data from database to beans [just does select too many times
> and get's next sequence, but not really a problem yet]
> - Updating data does does not work:
>    + it does UPDATE to file_categories (Category) but INSERT on
> category_names (CategoryName)
>    + does not have correct category_id while doing INSERT (which it
> should never do)
> - Deleting data does not work (referential integrity violation)
>    + it tries to delete first from file_categories (Category) ->
> referential error because there is data in category_names
> (CategoryName)
> - Inserting data does not work
>    + it does not pass category_id to category_names (CategoryName)
>    + does INSERT to the category_names (CategoryName) before
> file_categories (Category) -> if category_id would be passed ->
> referential error
>
> I made database simplier to like this:
>
> CREATE TABLE file_categories (
>   ID SERIAL.
> PRIMARY KEY (ID));
>
> CREATE TABLE category_names (
>   ID SERIAL,
>   CATEGORY_ID INTEGER NOT NULL,
>   NAME VARCHAR(50),
> PRIMARY KEY (ID),
> FOREIGN KEY (CATEGORY_ID) REFERENCES file_categories (ID));
>
> Category.java has:
>
> ...
> private int id;
> pricate Collection names = new ArrayList();
> ...
> setters/getters for id
> setters/getters for names
>
> public addNames (CategoryName name) {
>   names.add (name);
> }
> ...
> ------------
> CategoryName.java has:
> private int id;
> private int category_id;
> private String name;
>
> and I have getters/setters for everyone of those
> ---------
>
> repository.xml
> <descriptor-repository version="1.0" isolation-level="read-uncommitted">
>   <jdbc-connection-descriptor jcd-alias="testdb"
> default-connection="true" platform="PostgreSQL"
> subprotocol="postgresql">
>    <sequence-manager
> className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImp
> l"/>
>   </jdbc-connection-descriptor>
>   <class-descriptor class="net.vettenranta.category.bean.Category"
> table="FILE_CATEGORIES">
>    <field-descriptor name="id"
>                                  primarykey="true"
>                                  nullable="false"
>                                  default-fetch="true"
>                                  autoincrement="true"
>                                  column="ID"
>                                  sequence-name="file_categories_id_seq"
>                                  jdbc-type="INTEGER"
>                                  access="readonly"/>
>     <collection-descriptor name="names"
>
> element-class-ref="net.vettenranta.category.bean.CategoryName"
>
> collection-
> class="org.apache.ojb.broker.util.collections.ManageableArrayList"
>                                  otm-dependent="true">
>                          <inverse-foreignkey field-ref="category_id"/>

  in "<inverse-foreignkey field-ref="category_id"/>" i think this is a
  problem: the field category_id does not exist in the table
  FILE_CATEGORIES, although the field category_id exist in the table
  CATEGORY_NAMES.

  This is what I would do:
  Rename the field "ID" to "CATEGORY_ID" in table file_categories, well
  of course made the chandes in the repoitory.xml

  There are other attribute in for the "collection-descriptor" element
  like "auto-update" and "auto-delete" try put to true the value of this
  attribute.

  Cheers,
  Carlos Ch�vez.

>     </collection-descriptor>
>    </class-descriptor>
>    <class-descriptor class="net.vettenranta.category.bean.CategoryName"
> table="CATEGORY_NAMES">
>     <field-descriptor name="id"
>                                  primarykey="true"
>                                  nullable="false"
>                                  default-fetch="true"
>                                  column="ID"
>                                  jdbc-type="INTEGER"
>                                  autoincrement="true"
>                                  sequence-name="category_names_id_seq"
> access="readonly"/>
>         <field-descriptor name="category_id"
>                                  nullable="false"
>                                  default-fetch="true"
>                                  column="CATEGORY_ID"
>                                  jdbc-type="INTEGER" />
>        <field-descriptor name="name"
>                                  default-fetch="true"
>                                  column="NAME"
>                                  jdbc-type="VARCHAR"/>
>   </class-descriptor>
> ---------------
> --
> "Always remember that you are unique, just like everyone else!"
> * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 *
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
Carlos Ch�vez

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to