Re: Mapping a List (or Set) with OJB.
Hi Johan, Johan Andersson wrote: Greetings! Say I have a class MyClass it looks like this: public class MyClass { private int id; private String name; private List myIntegers = new ArrayList; /* getters and setters omitted ... */ } What options do I have if I want to persist this class using OJB? The List is causing me problems since it is not a pesistent entity class. Requirements impede me from just putting it into one field and use a IntList2VarcharFieldConversion. Requrements want me to have the List data in a separate database table. But I just cant figure out how to map this. Sorry, to have the List data in a separate database table is not supported by OJB. In this case OJB expect a persistence capable class e.g. Items. regards, Armin Here's my tables (I am using MySQL): CREATE TABLE `MY_CLASS` ( `id` int(10) unsigned NOT NULL auto_increment, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE `ITEMS` ( `my_class_id` int(10) unsigned NOT NULL, `item_id` int(10) unsigned NOT NULL, PRIMARY KEY (`my_class_id`, `item_id`) ); Thankful for any suggestions. /JOHAN - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping hierarchy in one table problem
It's no shame! It's something that can co on with everybody. I think that all of us we have something like that to tell..:-) On 2/11/08, Schmidt <[EMAIL PROTECTED]> wrote: > > > Hi Alessandro, > > Yes, you are right, it's a typho. But it does not reflect my real code. > > Nevertheless, I have found the answer. It's "shame on me". OJB has nothing > do do with that. I forgot to include a reference to the GrandChildProject > mapping file (&grandChildProject;) in the repository.xml file. So, OJB > could > not find where the mapping file is and returned a version of its mapped > parent. > Three days lost trying to find a good excuse :( > Sorry and don't forget to include all mapping files in the repository.xml > file. > > Thanks to all! > -- > View this message in context: > http://www.nabble.com/Mapping-hierarchy-in-one-table-problem-tp15354434p15410421.html > Sent from the Apache DB - ObjectRelationalBridge Users mailing list > archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Mapping hierarchy in one table problem
Hi Alessandro, Yes, you are right, it's a typho. But it does not reflect my real code. Nevertheless, I have found the answer. It's "shame on me". OJB has nothing do do with that. I forgot to include a reference to the GrandChildProject mapping file (&grandChildProject;) in the repository.xml file. So, OJB could not find where the mapping file is and returned a version of its mapped parent. Three days lost trying to find a good excuse :( Sorry and don't forget to include all mapping files in the repository.xml file. Thanks to all! -- View this message in context: http://www.nabble.com/Mapping-hierarchy-in-one-table-problem-tp15354434p15410421.html Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping hierarchy in one table problem
Just having a first superficial look. I see in your code GenericDAOApacheOJB grandChildProjectDao I didn't see GrandChildObject anywere else in your mapping, but maybe I'm not seeing well. Shouldn't it be GenericDAOApacheOJB ? On 2/11/08, Schmidt <[EMAIL PROTECTED]> wrote: > > > Hi Armin, > > Thanks again. > In order to query the database for GrandChildProject objects, I use a > generic class that extends PersistenceBrokerDaoSupport: > > public class GenericDAOApacheOJB extends > PersistenceBrokerDaoSupport > { > >private Class persistentClass; > >public T getById(PK id) throws DataAccessException{ >return (T) > this.getPersistenceBrokerTemplate().getObjectById(persistentClass, id); >} > > } > > And this is how I use the generic class: > > GenericDAOApacheOJB grandChildProjectDao; > grandChildProjectDao.getById(1245L); > > The project identified by the id 1245 is a GrandChildProject > (className="br.com.xxx.model.GrandChildProject"). The persistentClass > attribute points to the correct class (GrandChildProject) but somehow OJB > returns a ChildProject reference. I'm really stuck. > > One more doubt regarding mapping class hierarchy in one table. Is it > necessary to declare all subclasses of Project in the extents section or > just the "direct subclass"? > Ex: > > > > or > > > > > > Thanks in advance! > > -- > View this message in context: > http://www.nabble.com/Mapping-hierarchy-in-one-table-problem-tp15354434p15409604.html > Sent from the Apache DB - ObjectRelationalBridge Users mailing list > archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Mapping hierarchy in one table problem
Hi Armin, Thanks again. In order to query the database for GrandChildProject objects, I use a generic class that extends PersistenceBrokerDaoSupport: public class GenericDAOApacheOJB extends PersistenceBrokerDaoSupport { private Class persistentClass; public T getById(PK id) throws DataAccessException{ return (T) this.getPersistenceBrokerTemplate().getObjectById(persistentClass, id); } } And this is how I use the generic class: GenericDAOApacheOJB grandChildProjectDao; grandChildProjectDao.getById(1245L); The project identified by the id 1245 is a GrandChildProject (className="br.com.xxx.model.GrandChildProject"). The persistentClass attribute points to the correct class (GrandChildProject) but somehow OJB returns a ChildProject reference. I'm really stuck. One more doubt regarding mapping class hierarchy in one table. Is it necessary to declare all subclasses of Project in the extents section or just the "direct subclass"? Ex: or Thanks in advance! -- View this message in context: http://www.nabble.com/Mapping-hierarchy-in-one-table-problem-tp15354434p15409604.html Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping hierarchy in one table problem
Schmidt wrote: Upgraded to 1.0.4 and the problem persists. Any idea? In OJB test-suite we run several tests using table per hierarchy inheritance without any problems. So please, post all information to reproduce your issue - java source code or pseudo code of the java objects and the query. regards, Armin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping hierarchy in one table problem
Upgraded to 1.0.4 and the problem persists. Any idea? -- View this message in context: http://www.nabble.com/Mapping-hierarchy-in-one-table-problem-tp15354434p15361892.html Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping hierarchy in one table problem
Thanks for the answer! I was using 1.0.3 but now I'm upgrading to 1.0.4 to see if my luck changes Armin Waibel wrote: > > Hi, > > which version of OJB do you use? > > Schmidt wrote: >> Hi, >> >> I'm facing a hard time trying to fix a problem in my app. Consider the >> floowing class hierarchy: >> class Project {..} >> class ChildProject extends Project {..} >> class GrandChildProject extends ChildProject {..} >> > > How do you set the ojbConcreteClass attribute in your java object? > >> All these classes are mapped to the same table: PROJECT_TABLE >> >> Here are the mappings: >> >> >> >> ...some fields here... >> > jdbc-type="VARCHAR" /> >> >> >> > class="br.com.xxx.model.ChildProject"> >> >> ...some fields here... >> > jdbc-type="VARCHAR" /> >> >> >> > class="br.com.xxx.model.GrandChildProject "> >> ...some fields here... >> > jdbc-type="VARCHAR" /> >> >> >> Somehow when I search for GrandChildProject objects, OJB returns a >> ChildProject reference. This ends up in a ClassCastException. Is there >> anything wrong in the mappings or strategy used in this example? > > The mapping seems ok. > > regards, > Armin > >> >> Thanks in advance! > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Mapping-hierarchy-in-one-table-problem-tp15354434p15361600.html Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping hierarchy in one table problem
Hi, which version of OJB do you use? Schmidt wrote: Hi, I'm facing a hard time trying to fix a problem in my app. Consider the floowing class hierarchy: class Project {..} class ChildProject extends Project {..} class GrandChildProject extends ChildProject {..} How do you set the ojbConcreteClass attribute in your java object? All these classes are mapped to the same table: PROJECT_TABLE Here are the mappings: ...some fields here... ...some fields here... ...some fields here... Somehow when I search for GrandChildProject objects, OJB returns a ChildProject reference. This ends up in a ClassCastException. Is there anything wrong in the mappings or strategy used in this example? The mapping seems ok. regards, Armin Thanks in advance! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping hierarchy in one table problem
Any clue? I've spent the last 4 hours trying to figure out what can be wrong, but the problem persists. I'm running out of ideas :( -- View this message in context: http://www.nabble.com/Mapping-hierarchy-in-one-table-problem-tp15354434p15359642.html Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping hierarchy in one table problem
One More detail: as I said, the search results in a ChildProject reference instead of GrandChildProject. However, the ojbConcreteClass attribute in this ChildProject is set to "br.com.xxx.model.GrandChildProject". If ojbConcreteClass points to "br.com.xxx.model.GrandChildProject", how can OJB creates a ChildProject? -- View this message in context: http://www.nabble.com/Mapping-hierarchy-in-one-table-problem-tp15354434p15354534.html Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping for type BIT broke afer upgrade from 1.0.1 to 1.0.4
Hi Oliver, Oliver Seimel wrote: Hi, we migrated from ojb 1.0.1 to 1.0.4 DB is Postgres. But I think, that the "problem" is independent of the DB. We use the type BIT(1) for boolean values, so a mapping looks like this: With version 1.0.1 the generated SQL was ... WHERE emailnotice = '1' . With version 1.0.4 the generated SQL is ... WHERE emailnotice = 'true' . Thats not good, because the statement fails. Does anybody know why ojb now maps the BIT types to BOOLEAN? OJB 1.0.4 and higher try to support the JDBC 3.0 specification which specify to map BIT to boolean http://db.apache.org/ojb/docu/guides/jdbc-types.html Maybe this cause your problem. Could you please post the query/criteria which produce the SQL shown above. regards, Armin Thank you very much Oliver - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping List's
Hi Markus, Markus Brigl wrote: Hi Armin, it didn't mean the order-by, which does an ordering related to an attribute. What I mean is the insert order in a list; if an object A has index 0 in the list I would expect it has the same index after fetching the list in a different transaction. At example with Hibernate it is possible to define a column, where the index of each object is stored; many JDO implementation do this without any required specification. Can I reach this target even with OJB? Sorry, AFAIK this is currently not possible with OJB. Please make a feature request in JIRA. regards, Armin regards Markus On Mon, 2006-03-27 at 11:51 +0200, Armin Waibel wrote: Hi Markus, Markus Brigl wrote: Hi, I have a problem with the mapping of List's. If I store the list to DB and reload it the order of the objects are casual and not the same as I inserted them in the List. Can I configure the repository file in some way that OBJ stores even the indexes of the List? Do you mean mapping of 1:n relations? In this case you can specify a "order-by" element in the collection-descriptor to force ordering. http://db.apache.org/ojb/docu/guides/repository.html#orderby regards, Armin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping List's
Hi Armin, it didn't mean the order-by, which does an ordering related to an attribute. What I mean is the insert order in a list; if an object A has index 0 in the list I would expect it has the same index after fetching the list in a different transaction. At example with Hibernate it is possible to define a column, where the index of each object is stored; many JDO implementation do this without any required specification. Can I reach this target even with OJB? regards Markus On Mon, 2006-03-27 at 11:51 +0200, Armin Waibel wrote: > Hi Markus, > > Markus Brigl wrote: > > Hi, > > > > I have a problem with the mapping of List's. If I store the list to DB > > and reload it the order of the objects are casual and not the same as I > > inserted them in the List. Can I configure the repository file in some > > way that OBJ stores even the indexes of the List? > > > > Do you mean mapping of 1:n relations? In this case you can specify a > "order-by" element in the collection-descriptor to force ordering. > http://db.apache.org/ojb/docu/guides/repository.html#orderby > > regards, > Armin > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping List's
Hi Markus, Markus Brigl wrote: Hi, I have a problem with the mapping of List's. If I store the list to DB and reload it the order of the objects are casual and not the same as I inserted them in the List. Can I configure the repository file in some way that OBJ stores even the indexes of the List? Do you mean mapping of 1:n relations? In this case you can specify a "order-by" element in the collection-descriptor to force ordering. http://db.apache.org/ojb/docu/guides/repository.html#orderby regards, Armin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping 2 or more all classes on the same table
Dear Ramakrishna, We had this feature since 2001! Please note that OJB is not based on lies ! for details refer to the documentation under http://db.apache.org/ojb/docu/guides/advanced-technique.html#Mapping+All+Classes+on+the+Same+Table cheers, Thomas Ramakrishna Reddy wrote: Hi, Do we have proper calssDecriminator (Mapping the all classes on the same table.) mechanism without side effects in OJB, on the same lies of Hibernate? In the documentation is it just mentioned, but not sufficient details and examples are gives on that Regards, Ramki Regards, Ramakrishna Reddy N - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping Classes on Multiple Joined Tables
So is it now possible to combine the extent concept with a mapping on multiple joined tables? What would be the expected behavior in such a scenario? ... ... -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Thursday, April 21, 2005 12:16 PM To: OJB Users List Subject: Re: Mapping Classes on Multiple Joined Tables Jakob Braeuchi wrote: >> >> The issue is noted in the release-notes: >> >> >> - When a class mapped on multiple joined tables was used in a >> reference only objects >> of the base type class will be instantiated, e.g. a Company class has >> a 1:n reference 'employees' to a base class Employee and class >> Manager extends Employee, >> then 'employees' only contains objects of type Employee even if the >> real type was Manager. >> See in OJB test suite >> ...broker.InheritanceMultipleTableTest#testInheritancedObjectsInColle >> ctionReferences >> >> Same problem occur when query the base class, then OJB only returns >> objects of base type instead >> the real type. >> >> >> But I admit my English is abstruse ;-) > > > you're right, i do not understand it :( > That's why I wrote the test case. Maybe you can rephrase this section in release-notes, or much better finding a solution for the problem ;-) I will check in my changes (first alpha version) for this kind of inheritance today plus some new tests. But it will not solve the problem described above. regards, Armin > jakob > >> >> regards, >> Armin >> >> >> >>> Thank you, >>> stefan walkner >>> >>> >>> - To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping Classes on Multiple Joined Tables
Jakob Braeuchi wrote: The issue is noted in the release-notes: - When a class mapped on multiple joined tables was used in a reference only objects of the base type class will be instantiated, e.g. a Company class has a 1:n reference 'employees' to a base class Employee and class Manager extends Employee, then 'employees' only contains objects of type Employee even if the real type was Manager. See in OJB test suite ...broker.InheritanceMultipleTableTest#testInheritancedObjectsInCollectionReferences Same problem occur when query the base class, then OJB only returns objects of base type instead the real type. But I admit my English is abstruse ;-) you're right, i do not understand it :( That's why I wrote the test case. Maybe you can rephrase this section in release-notes, or much better finding a solution for the problem ;-) I will check in my changes (first alpha version) for this kind of inheritance today plus some new tests. But it will not solve the problem described above. regards, Armin jakob regards, Armin Thank you, stefan walkner - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping Classes on Multiple Joined Tables
hi armin, Armin Waibel schrieb: Stefan Walkner wrote: hello, we start working on this issue. Hope till next release this will be fixed. thank you for the info! I really was searching long and was not able to find any information about that, so I'm glad to hear any response from you. The issue is noted in the release-notes: - When a class mapped on multiple joined tables was used in a reference only objects of the base type class will be instantiated, e.g. a Company class has a 1:n reference 'employees' to a base class Employee and class Manager extends Employee, then 'employees' only contains objects of type Employee even if the real type was Manager. See in OJB test suite ...broker.InheritanceMultipleTableTest#testInheritancedObjectsInCollectionReferences Same problem occur when query the base class, then OJB only returns objects of base type instead the real type. But I admit my English is abstruse ;-) you're right, i do not understand it :( jakob regards, Armin Thank you, stefan walkner - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping Classes on Multiple Joined Tables
Stefan Walkner wrote: hello, we start working on this issue. Hope till next release this will be fixed. thank you for the info! I really was searching long and was not able to find any information about that, so I'm glad to hear any response from you. The issue is noted in the release-notes: - When a class mapped on multiple joined tables was used in a reference only objects of the base type class will be instantiated, e.g. a Company class has a 1:n reference 'employees' to a base class Employee and class Manager extends Employee, then 'employees' only contains objects of type Employee even if the real type was Manager. See in OJB test suite ...broker.InheritanceMultipleTableTest#testInheritancedObjectsInCollectionReferences Same problem occur when query the base class, then OJB only returns objects of base type instead the real type. But I admit my English is abstruse ;-) regards, Armin Thank you, stefan walkner - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping Classes on Multiple Joined Tables
hello, > we start working on this issue. Hope till next release this will be fixed. thank you for the info! I really was searching long and was not able to find any information about that, so I'm glad to hear any response from you. Thank you, stefan walkner - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping Classes on Multiple Joined Tables
Hi Stefan, Stefan Walkner wrote: hello, I use Mapping Classes on Multiple Joined Tables to map an Object which inherits from another into two tables. BUT: is there a way to get the different objects back, when querying? I mean, I have following mappings: we start working on this issue. Hope till next release this will be fixed. regards, Armin -- name="itemCode" column="fk_item_code" jdbc-type="INTEGER" primarykey="true" /> name="isbn" column="isbn" jdbc-type="VARCHAR" /> name="author" column="author" jdbc-type="VARCHAR" /> name="publisher" column="publisher" jdbc-type="VARCHAR" /> auto-retrieve="true" auto-update="true" auto-delete="true" > -- but when doing a query by Criteria: new QueryByCriteria(Item.class); I DO not get the "books" as book > instead they are just items :( I also used in the item mapping "extends" but this did not solve my problem... It would be very nice if someone could tell me where my problem is. thanks in advance, stefan walkner - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping one object in different RDBMS - source
Armin, thanks for your reply. But one more thing. I use table with something like 100 000 records. Using of PB.getCollectionByQuery may couse problems with memory. Out Of Memory Exception for example. This is not a problem - I can increase heap size for JVM, etc.In this case using PB.getIteratorByQuery sounds logic, I think. How I can use multiply repository profiles and still use PB.getIteratorByQuery ? I thik it will be coll when I can dynamically change only table name and operate with same object but in different db. Mapping for particular object I have alredy, one thing I need to be changed at runtime is table name. Is it possible in fact to work with big data sets in few RDBMSs ? Anyone have such expirience ? Thank you. On Mon, 11 Apr 2005 11:40:16 +0200, Armin Waibel <[EMAIL PROTECTED]> wrote: > Hi, > > Stas Ostapenko wrote: > > I have a problem with inserting all table data of one table to another > > table in other RDBMS. Following code works, but it stores not all the > > data, but only first object. > > Where I`m wrong ? > > First you have to take care that metadata changes are global operations, > all metadata are shared. > http://db.apache.org/ojb/docu/guides/metadata.html#Global%0A > > If you change the table name of a class-descriptor all other PB/threads > will use the changed table name. > > In a single threaded application you can change metadata in the > following way: > > - Lookup the PB of the source DB > - get the objects you want to copy, use PB.getCollectionByQuery instead > of PB.getIteratorByQuery (to guarantee that the objects be materialized > before the metadata change, avoid lazy materialization settings in > metadata) > - close the PB > - change the table name > - Lookup PB for target DB > - begin PB-tx > - loop and copy > - PB-tx commit > > A more elegant and multithreaded safe solution will be the usage of > different metadata profiles. You have a "normal" repository file with > all class-descriptor (with source table names) and an additionally > "profile" repository file with all class-descriptor using the target DB > table names. This profile is read at runtime (e.g. at start of your > application) and you are using the MetadataManager to setup a "source" > and a "target" metadata-profile. More detailed info here > > http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes > > regards, > Armin > > > > Please help. > > > > import org.apache.ojb.broker.PersistenceBroker; > > import org.apache.ojb.broker.PersistenceBrokerException; > > import org.apache.ojb.broker.PersistenceBrokerFactory; > > import org.apache.ojb.broker.query.QueryByCriteria; > > import org.apache.ojb.broker.query.Criteria; > > import org.apache.ojb.broker.metadata.DescriptorRepository; > > import org.apache.ojb.broker.metadata.FieldDescriptor; > > import org.apache.ojb.broker.metadata.MetadataManager; > > import org.apache.ojb.broker.metadata.ClassDescriptor; > > > > import java.util.Iterator; > > > > public class From_MySQL_2_HSQL_DB_testing > > { > > public static void main(String args[]) > > { > > PersistenceBroker hsql_db_broker = null; > > > > PersistenceBroker mysql_db_broker = null; > > > > Object result = null; > > > > ClassDescriptor hsql_db_Domain_classDescriptor = null; > > ClassDescriptor mysql_db_Domain_classDescriptor = null; > > try > > { > > hsql_db_broker = > > PersistenceBrokerFactory.createPersistenceBroker("HSQL_OJB_Files", > > "root", ""); > > > > mysql_db_broker = > > PersistenceBrokerFactory.createPersistenceBroker("MySQL_Main_Database", > > "root", ""); > > > > hsql_db_Domain_classDescriptor = > > hsql_db_broker.getClassDescriptor(Domain.class); > > hsql_db_Domain_classDescriptor.setTableName("hsqldb_domain"); > > > > mysql_db_Domain_classDescriptor = > > mysql_db_broker.getClassDescriptor(Domain.class); > > mysql_db_Domain_classDescriptor.setTableName("domain"); > > > > Criteria criteria = new Criteria(); > > > > criteria.addLike("Domain", "%"); > > QueryByCriteria query = new QueryByCriteria(Domain.class, > criteria); > > > > Iterator bdIterator = mysql_db_broker.getIteratorByQuery(query); > > > > while(bdIterator.hasNext()) > > { > > mysql_db_Domain_classDescriptor.setTableName("domain"); > > result = bdIterator.next(); > > > > hsql_db_Domain_classDescriptor.setTableName("hsqldb_domain"); > > hsql_db_broker.beginTransaction(); > > hsql_db_broker.store(result); > > hsql_db_broker.commitTransaction(); > > System.out.println(((Domain)result).Name); > > } > > } > > catch(Exception e) > > { > > e.printStackTrace(); > > } > > finally > > { > > //close HSQLDB connection > > hsql_db_broker.close(); > > > > //close MySQL connection > >
Re: mapping one object in different RDBMS - source
Hi, Stas Ostapenko wrote: I have a problem with inserting all table data of one table to another table in other RDBMS. Following code works, but it stores not all the data, but only first object. Where I`m wrong ? First you have to take care that metadata changes are global operations, all metadata are shared. http://db.apache.org/ojb/docu/guides/metadata.html#Global%0A If you change the table name of a class-descriptor all other PB/threads will use the changed table name. In a single threaded application you can change metadata in the following way: - Lookup the PB of the source DB - get the objects you want to copy, use PB.getCollectionByQuery instead of PB.getIteratorByQuery (to guarantee that the objects be materialized before the metadata change, avoid lazy materialization settings in metadata) - close the PB - change the table name - Lookup PB for target DB - begin PB-tx - loop and copy - PB-tx commit A more elegant and multithreaded safe solution will be the usage of different metadata profiles. You have a "normal" repository file with all class-descriptor (with source table names) and an additionally "profile" repository file with all class-descriptor using the target DB table names. This profile is read at runtime (e.g. at start of your application) and you are using the MetadataManager to setup a "source" and a "target" metadata-profile. More detailed info here http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes regards, Armin Please help. import org.apache.ojb.broker.PersistenceBroker; import org.apache.ojb.broker.PersistenceBrokerException; import org.apache.ojb.broker.PersistenceBrokerFactory; import org.apache.ojb.broker.query.QueryByCriteria; import org.apache.ojb.broker.query.Criteria; import org.apache.ojb.broker.metadata.DescriptorRepository; import org.apache.ojb.broker.metadata.FieldDescriptor; import org.apache.ojb.broker.metadata.MetadataManager; import org.apache.ojb.broker.metadata.ClassDescriptor; import java.util.Iterator; public class From_MySQL_2_HSQL_DB_testing { public static void main(String args[]) { PersistenceBroker hsql_db_broker = null; PersistenceBroker mysql_db_broker = null; Object result = null; ClassDescriptor hsql_db_Domain_classDescriptor = null; ClassDescriptor mysql_db_Domain_classDescriptor = null; try { hsql_db_broker = PersistenceBrokerFactory.createPersistenceBroker("HSQL_OJB_Files", "root", ""); mysql_db_broker = PersistenceBrokerFactory.createPersistenceBroker("MySQL_Main_Database", "root", ""); hsql_db_Domain_classDescriptor = hsql_db_broker.getClassDescriptor(Domain.class); hsql_db_Domain_classDescriptor.setTableName("hsqldb_domain"); mysql_db_Domain_classDescriptor = mysql_db_broker.getClassDescriptor(Domain.class); mysql_db_Domain_classDescriptor.setTableName("domain"); Criteria criteria = new Criteria(); criteria.addLike("Domain", "%"); QueryByCriteria query = new QueryByCriteria(Domain.class, criteria); Iterator bdIterator = mysql_db_broker.getIteratorByQuery(query); while(bdIterator.hasNext()) { mysql_db_Domain_classDescriptor.setTableName("domain"); result = bdIterator.next(); hsql_db_Domain_classDescriptor.setTableName("hsqldb_domain"); hsql_db_broker.beginTransaction(); hsql_db_broker.store(result); hsql_db_broker.commitTransaction(); System.out.println(((Domain)result).Name); } } catch(Exception e) { e.printStackTrace(); } finally { //close HSQLDB connection hsql_db_broker.close(); //close MySQL connection mysql_db_broker.close(); } } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
I now have a running version, but the way Thomas proposed would be much nicer. I have added a collection descriptor and he returns both addresses. I tried to modify my getters and setters for addresses to set homeAddress and workAddress, but I tested this and noticed that they are not invoked (why should they? (*grml*)) So I added a function assignAddresses(), which is invoked by the DAO getUser method. public void addressAssignment() { Iterator i = this.adresses.iterator(); while (i.hasNext()) { Adress address = (Address) i.next(); if ("home".equals(adress.getType())) this.homeAddress = address; if ("work".equals(adress.getType())) this.workAddress = address; } } Now I have to take care that every setHomeAddress also modifies the collection (because I don't think that getAddresses() is invoked by ojb either ;) ) May be I implement a query costomizer who filters the addresses like described in the advanced mapping tutorial: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping question
i tried to change my code to using extends, it works perfect for me, and from an object oriented design view, this is perfect! what i did (if i apply the things i did to georgs problem): - create an abstract class Address that has all attributes in it - derive both classes HomeAddress and WorkAddress from Address - setup the constructor of both classes as described in http://db.apache.org/ojb/docu/guides/advanced-technique.html#Extents+and+Pol ymorphism - setup the repository.xml as described in the chapter http://db.apache.org/ojb/docu/guides/advanced-technique.html#Mapping+All+Cla sses+on+the+Same+Table this works perfect for me and is much cleaner (but of course works only if you can change your db layout). if you can't change the layout, one possible solution is described in http://db.apache.org/ojb/docu/guides/advanced-technique.html#Mapping+All+Cla sses+on+the+Same+Table when showing how to implement your own ClassDescriptor. cool stuff! kr, guenther -Original Message- From: Georg Müller [mailto:[EMAIL PROTECTED] Sent: Thursday, March 03, 2005 11:33 PM To: OJB Users List Subject: Re: Mapping question Thomas Dudziak wrote: > As far as I understand he wants to use a reference that refers to a > class with a compound primarykey, where one of the foreignkey values > is fixed: > >class-ref="Address" > auto-update="true" > auto-delete="true"> > > > > Yes, that is what I am searching for. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
Thomas Dudziak wrote: As far as I understand he wants to use a reference that refers to a class with a compound primarykey, where one of the foreignkey values is fixed: Yes, that is what I am searching for. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
As far as I understand he wants to use a reference that refers to a class with a compound primarykey, where one of the foreignkey values is fixed: That would actually be a neat feature to have IMO ?! Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
Hi, not sure that I understand the problem. Each User has two Address attributes ('home' and 'work'), both are of the same type 'Address' (both 1:1 references), you don't use extension classes AddressHome and AddressWork objects. Address use a composite PK ('login' and 'type'). In this case each reference has to use a composite FK key too. in User (assume the 'login' datatype is INTEGER and User use an autoincrement PK, only show mapping for the 'home' reference, 'work' will be the same): You need a FK field for each PK value of the referenced object, if you use 'anonymous' fields, you don't need a "real" fields in your persistent object class (User) - more info see docs. http://db.apache.org/ojb/docu/guides/advanced-technique.html#How+do+ In Address you use the composite PK and both attributes has to be set by hand (no PK auto-generation was used) and the 'login' field is a FK from User table. This will make things complicated, because on insert OJB will first store the 1:1 references, but in your case we need the 'login' PK first. So we need a workaround when insert User objects: broker.beginTransaction(); User user = new User(); broker.store(user); // now the PK ('login' field in User) is specified Address home = new Address(); home.setLogin(user.getLogin()); home.setType("home"); user.setHome(home); // broker.store(user); broker.commitTransaction(); Things will be easier when you use an single autoincremented PK field in Address. In this case all will be handled by OJB and you only need single FK field-descriptor in User: broker.beginTransaction(); User user = new User(); Address home = new Address(); home.setType("home"); user.setHome(home); broker.store(user); broker.commitTransaction(); regards, Armin Günther Wieser wrote: hi, as far as i understand this, you try to differentiate by the value of "adress.type" whether an adress is a home wor work adress? well, i have no solution for that, but i tried it here with a similair data structur, and it didn't work either. to be honest i'm not sure if this is the intended use for in or , because i didn't find anything in the docs. all i found was an example in the ojb test cases in repository_junit.xml, but the corresponding source code didn't tell me anything i could understand. so, long speach, short meaning: i'm also interested in a solution for that! kr, guenther -Original Message- From: Georg Müller [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 02, 2005 9:24 PM To: ojb-user@db.apache.org Subject: Mapping question Hi, I have an object "User" who has 2 addresses, home and work. User is mapped to a table user (no problem here). Both home and work address are mapped to a table address. This table has a composite primary key: login and type - login from table user as a foreign key - type is a string (or enum) "home" and "work" I have tried the following without success: in User description: and in Address description: Is it possible to make it run anyhow? Regards, Georg P.S.: Please CC me - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping question
hi, as far as i understand this, you try to differentiate by the value of "adress.type" whether an adress is a home wor work adress? well, i have no solution for that, but i tried it here with a similair data structur, and it didn't work either. to be honest i'm not sure if this is the intended use for in or , because i didn't find anything in the docs. all i found was an example in the ojb test cases in repository_junit.xml, but the corresponding source code didn't tell me anything i could understand. so, long speach, short meaning: i'm also interested in a solution for that! kr, guenther -Original Message- From: Georg Müller [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 02, 2005 9:24 PM To: ojb-user@db.apache.org Subject: Mapping question Hi, I have an object "User" who has 2 addresses, home and work. User is mapped to a table user (no problem here). Both home and work address are mapped to a table address. This table has a composite primary key: login and type - login from table user as a foreign key - type is a string (or enum) "home" and "work" I have tried the following without success: in User description: and in Address description: Is it possible to make it run anyhow? Regards, Georg P.S.: Please CC me - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
Sorry for that second posting. I sent this before I subscribed to the list, so I thought it will not be posted (now, with a latency of nearly one day) Regards, Georg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping class to multiple tables?
Hi Bobby, [EMAIL PROTECTED] wrote: Armin - In your response to Jesse in the enclosed email, you stated that "If you want to map a class to multiple tables of different databases you always have to handle this by your own, because there are many pitfals: need of distributed tx, querying, " I need to accomplish this for a project that I am working on. It was my understanding that this was possible with OJB. no, not out of the box. You cannot configure this without having to do it at runtime? right If not, does this mean that any class I define with my descriptor in the repository.xml file only uses the database that is currently connected? yep, the used PersistenceBroker instance only work on one connection at the same time. It would be nice if OJB knew what datasource it had to go to to build the class. This will be partially possible when using custom attributes to specify the datasource/jcdAlias associated with the class in the class-descriptor. Then you can decide at runtime which DB to use. ... Get the attribute via // get the ClassDescriptor, you can use the MetadataManager // too to lookup the ClassDescriptor ClassDescriptor cld = broker.getClassDescriptor(TestClass.class); String value = cld.getAttribute("associatedDB"); now you can check if the current used PB instance match the found jcdAlias name (e.g. with broker.getPBKey().getAlias()). If not lookup another PB instance. But you have to handle this by your own. regards, Armin --Bobby From: Armin Waibel <[EMAIL PROTECTED]> Subject: mapping class to multiple tables? Date: Mon, 17 Feb 2003 11:18:32 +0100 Content-Type: text/plain; charset="iso-8859-1" Hi Jesse, - Original Message - From: "Jesse Vitrone" <[EMAIL PROTECTED]> To: Sent: Sunday, February 16, 2003 3:34 PM Subject: mapping class to multiple tables? Sorry, I'm sure this is the docs somewhere, but I just can't seem to find it. The features list shows this feature: Classes can be mapped to an arbitrary number of JDBC datasources. this is possible (use of multiple databases), but your question is to map a class to multiple tables (of the same database?). I'm not sure, think currently this is only possible by delegate the calls from the main class to subsequent classes using 1:1 references. see http://db.apache.org/ojb/tutorial3.html#mapping classes on multiple joined tables class Main { private Sub1 sub1; private Sub2 sub2; public String getName() { return sub1.getName() } . } If you want to map a class to multiple tables of different databases you always have to handle this by your own, because there are many pitfals: need of distributed tx, querying, regards, Armin Where in the docs does it show how to do this? I read through the advanced O/R tutorial, and I don't see it. Did I just miss it? I'm just getting started with OJB, but it looks great so far! Thanks in advance, Jesse - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping class to multiple tables?
Armin - In your response to Jesse in the enclosed email, you stated that "If you want to map a class to multiple tables of different databases you always have to handle this by your own, because there are many pitfals: need of distributed tx, querying, " I need to accomplish this for a project that I am working on. It was my understanding that this was possible with OJB. You cannot configure this without having to do it at runtime? If not, does this mean that any class I define with my descriptor in the repository.xml file only uses the database that is currently connected? It would be nice if OJB knew what datasource it had to go to to build the class. --Bobby From: Armin Waibel <[EMAIL PROTECTED]> Subject: mapping class to multiple tables? Date: Mon, 17 Feb 2003 11:18:32 +0100 Content-Type: text/plain; charset="iso-8859-1" Hi Jesse, - Original Message - From: "Jesse Vitrone" <[EMAIL PROTECTED]> To: Sent: Sunday, February 16, 2003 3:34 PM Subject: mapping class to multiple tables? > Sorry, I'm sure this is the docs somewhere, but I just can't seem to > find it. > > The features list shows this feature: > Classes can be mapped to an arbitrary number of JDBC datasources. this is possible (use of multiple databases), but your question is to map a class to multiple tables (of the same database?). I'm not sure, think currently this is only possible by delegate the calls from the main class to subsequent classes using 1:1 references. see http://db.apache.org/ojb/tutorial3.html#mapping classes on multiple joined tables class Main { private Sub1 sub1; private Sub2 sub2; public String getName() { return sub1.getName() } . } If you want to map a class to multiple tables of different databases you always have to handle this by your own, because there are many pitfals: need of distributed tx, querying, regards, Armin > > Where in the docs does it show how to do this? I read through the > advanced O/R tutorial, and I don't see it. Did I just miss it? > > I'm just getting started with OJB, but it looks great so far! > > Thanks in advance, > Jesse > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping a simple class problem.
Thanks Armin, You were right, I have amended the typos I am not getting any Exception and I am making the objects persistent without problems. At the moment everything is going OK, but I am sure I will find more problems. Regards... - Original Message - From: "Armin Waibel" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Monday, October 04, 2004 11:07 PM Subject: Re: Mapping a simple class problem. Hi Jose, the exception says that UserBO does not declare at least one PK field. > Caused by: > org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: OJB > needs at least one primary key attrib > ute for class objectsRealClass=class > com.jose.forum.businessobjects.UserBO, In UserBO you set > name="id" > column="id" > jdbc_type="INTEGER" > primaryKey="true" > autoincrement="true" > /> But primaryKey="true" is a typo and should be primarykey="true". By the way 'jdbc_type' should be 'jdbc-type' - another typo. Good luck! regards, Armin Jose Felix Hernandez wrote: Hi, I´m just getting started and this is my problem trying to map a single class. Find below the table structure, the BusinessObject java class, the repository.xml, the class I´m using to run the test and the exception I´m getting. I hope somebody can help my to spot what is wrong... Thanks... The table structure is ... CREATE TABLE `user` ( `id` int(11) NOT NULL default '0', `firstName` varchar(50) default NULL, `lastName` varchar(50) default NULL, `email` varchar(50) default NULL, `password` varchar(50) default NULL, `status` char(1) default NULL, PRIMARY KEY (`id`) ) TYPE=InnoDB ROW_FORMAT=DYNAMIC; The BO is... package com.jose.forum.businessobjects; public class UserBO implements java.io.Serializable { private int id; private String firstName; private String lastName; private String email; private String password; private String accountStatus; //public UserBO(){ // super(); //} public int getId() { return id; } public void setId(int id) { this.id = id; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getAccountStatus() { return accountStatus; } public void setAccountStatus(String accountStaturs) { this.accountStatus = accountStatus; } } The repository-user.xml is... The class I´m using to test is... public class Test { static Implementation odmg = null; static Database db = null; public static void main(String args[]) throws ODMGException{ UserBO user = new UserBO(); user.setId(0); user.setFirstName("Jose"); user.setLastName("Hernandez"); user.setEmail("[EMAIL PROTECTED]"); user.setPassword("jose"); user.setAccountStatus("A"); init(); Transaction tx = odmg.newTransaction(); tx.begin(); db.makePersistent(user); tx.commit(); destroy(); } private static void destroy() throws ODMGException{ db.close(); } private static void init() throws ODMGException{ ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); JdbcConnectionDescriptor jcd = new JdbcConnectionDescriptor(); jcd.setJcdAlias("jfhForum"); jcd.setUserName("web"); jcd.setPassWord("web"); jcd.setDbAlias("jfhForum"); jcd.setDbms("MySQL"); cr.addDescriptor(jcd); PBKey key = new PBKey("jfhForum", "web", "web"); PersistenceBroker broker = PersistenceBrokerFactory. createPersistenceBroker(key); odmg = OJB.getInstance(); db = odmg.newDatabase(); db.open("jfhForum", Database.OPEN_READ_WRITE); } } I get the below exception... [org.apache.ojb.odmg.DatabaseImpl] ERROR: Persistence object failed: [EMAIL PROTECTED] Can not init Identity for given object [EMAIL PROTECTED] org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: Can not init Identity for given object com.jose.foru [EMAIL PROTECTED] at org.apache.ojb.broker.Identity.init(Identity.java:157) at org.apache.ojb.broker.Identity.(Identity.java:114) at org.apache.ojb.odmg.locking.InMemoryLockMapImpl.getWriter(InMemoryLockMapImpl.java:64) at org.apache.ojb.odmg.locking.AbstractLockStrategy.getWriter(AbstractLockStrategy.java:59) at org.apache.ojb.odmg.locking.ReadUncommittedStrategy.writeLock(ReadUncommittedStrategy.java:60) at org.apache.ojb.odmg.locking.LockManagerDefaultImpl.writeLock(LockManagerDefaultImpl.java:76) at org.apache.ojb.odmg.Transa
Re: Mapping a simple class problem.
Hi Jose, the exception says that UserBO does not declare at least one PK field. > Caused by: > org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: OJB > needs at least one primary key attrib > ute for class objectsRealClass=class > com.jose.forum.businessobjects.UserBO, In UserBO you set > name="id" > column="id" > jdbc_type="INTEGER" > primaryKey="true" > autoincrement="true" > /> But primaryKey="true" is a typo and should be primarykey="true". By the way 'jdbc_type' should be 'jdbc-type' - another typo. Good luck! regards, Armin Jose Felix Hernandez wrote: Hi, I´m just getting started and this is my problem trying to map a single class. Find below the table structure, the BusinessObject java class, the repository.xml, the class I´m using to run the test and the exception I´m getting. I hope somebody can help my to spot what is wrong... Thanks... The table structure is ... CREATE TABLE `user` ( `id` int(11) NOT NULL default '0', `firstName` varchar(50) default NULL, `lastName` varchar(50) default NULL, `email` varchar(50) default NULL, `password` varchar(50) default NULL, `status` char(1) default NULL, PRIMARY KEY (`id`) ) TYPE=InnoDB ROW_FORMAT=DYNAMIC; The BO is... package com.jose.forum.businessobjects; public class UserBO implements java.io.Serializable { private int id; private String firstName; private String lastName; private String email; private String password; private String accountStatus; //public UserBO(){ // super(); //} public int getId() { return id; } public void setId(int id) { this.id = id; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getAccountStatus() { return accountStatus; } public void setAccountStatus(String accountStaturs) { this.accountStatus = accountStatus; } } The repository-user.xml is... The class I´m using to test is... public class Test { static Implementation odmg = null; static Database db = null; public static void main(String args[]) throws ODMGException{ UserBO user = new UserBO(); user.setId(0); user.setFirstName("Jose"); user.setLastName("Hernandez"); user.setEmail("[EMAIL PROTECTED]"); user.setPassword("jose"); user.setAccountStatus("A"); init(); Transaction tx = odmg.newTransaction(); tx.begin(); db.makePersistent(user); tx.commit(); destroy(); } private static void destroy() throws ODMGException{ db.close(); } private static void init() throws ODMGException{ ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); JdbcConnectionDescriptor jcd = new JdbcConnectionDescriptor(); jcd.setJcdAlias("jfhForum"); jcd.setUserName("web"); jcd.setPassWord("web"); jcd.setDbAlias("jfhForum"); jcd.setDbms("MySQL"); cr.addDescriptor(jcd); PBKey key = new PBKey("jfhForum", "web", "web"); PersistenceBroker broker = PersistenceBrokerFactory. createPersistenceBroker(key); odmg = OJB.getInstance(); db = odmg.newDatabase(); db.open("jfhForum", Database.OPEN_READ_WRITE); } } I get the below exception... [org.apache.ojb.odmg.DatabaseImpl] ERROR: Persistence object failed: [EMAIL PROTECTED] Can not init Identity for given object [EMAIL PROTECTED] org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: Can not init Identity for given object com.jose.foru [EMAIL PROTECTED] at org.apache.ojb.broker.Identity.init(Identity.java:157) at org.apache.ojb.broker.Identity.(Identity.java:114) at org.apache.ojb.odmg.locking.InMemoryLockMapImpl.getWriter(InMemoryLockMapImpl.java:64) at org.apache.ojb.odmg.locking.AbstractLockStrategy.getWriter(AbstractLockStrategy.java:59) at org.apache.ojb.odmg.locking.ReadUncommittedStrategy.writeLock(ReadUncommittedStrategy.java:60) at org.apache.ojb.odmg.locking.LockManagerDefaultImpl.writeLock(LockManagerDefaultImpl.java:76) at org.apache.ojb.odmg.TransactionImpl.lock(TransactionImpl.java:249) at org.apache.ojb.odmg.DatabaseImpl.makePersistent(DatabaseImpl.java:374) at Test.main(Test.java:23) Caused by: org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: OJB needs at least one primary key attrib ute for class objectsRealClass=class com.jose.forum.businessobjects.UserBO, objectTopLevelClass=class com.jose.forum.bu sinessobjects.UserBO at org.apache.ojb.broker.Identity.checkForPrimaryKeys(Identity.java:277) at org.apache.ojb.broker.Identity.init(Identity.java:153) ... 8 more Exception in thread "main" org.odmg.ClassNotPersistenceCapableException: Can not init Identity for given object com.jose [EMAIL PROTECT
RE: mapping of the datetime type
Hi, java.sql.TimeStamp Cheers, Charles. > -Original Message- > From: Joncheng Kuo [mailto:[EMAIL PROTECTED] > Sent: 11 August 2004 17:26 > To: OJB Users List > Subject: mapping of the datetime type > > > Hi, > > I have a column of type 'datetime' in a MS SQL database. What type > should I use to map this column such that I can get the time > component? > Datetime is not listed in OJB's doc. It seems that OJB maps it to > java.sql.Date. > > Joncheng > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > ___ HPD Software Ltd. - Helping Business Finance Business Email terms and conditions: www.hpdsoftware.com/disclaimer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping the same class to multiple tables?
I have a similar solution in my job. I've done in the following way: class A { ... } class A_normal extends A { } class A_history extends A { } Only A_normal and A_history are mapped in repository.xml. So, if I need to manipulate the object, I use class A. To store a normal object, I use and instance of A_normal. If I need to store a history object, I use A_history. Now, if I need to move one object A_normal to A_history, I use the method copyProperties in common-beans library to do the job. The I start a transaction, delete A_normal and insert the A_history. I think can be several ways to get job done, this is just one. Best regards, Richter > My application has to support undo using persistence, as someone must be able to > change a > previously entered field after closing and re-opening the application. > > All of my classes extend my own PersistentObject class, but certain classes can be > entered > into the "History" (to be undone later), and those classes implement a marker > interface > called "Enterable". > > I'd like to have two methods as follows: > > store(PersistentObject) > storeEnterable(Enterable) > > where storeEnterable() would store the Enterable in a history table. Is this > possible? > > -- > Liam Morley > [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: mapping fields to an array
Thanks for the reply. It looks like I also may have to use a Rowreader to correctly store nested objects as well, so I may very well choose that approach. Thanks again. -- Liam Morley From: Thomas DudziakSent: Sun 6/27/04 4:58 AMTo: OJB Users ListSubject: Re: mapping fields to an array Morley, Liam wrote: We've got a db table with a structure like this: Name Address SSN Field1 Field2 ... Field30approx The guy who designed the java class for this (a bit more of a C-style programmer than I am) wrote a class structure like this: String name; Address address; String ssn; int[] fields; where fields is an array of length 30 that has the values of fields 1 through 30. (The fields actually have individual names, not Field1 Field2 etc.) is there a way to map my fields to an array, or do i have to have 30 internal variables? AFAIK the only way to do so is to use a custom row-reader implementation for the class. Check here for details: http://db.apache.org/ojb/docu/advanced-technique.html#using-rowreader Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping fields to an array
Morley, Liam wrote: We've got a db table with a structure like this: Name Address SSN Field1 Field2 ... Field30approx The guy who designed the java class for this (a bit more of a C-style programmer than I am) wrote a class structure like this: String name; Address address; String ssn; int[] fields; where fields is an array of length 30 that has the values of fields 1 through 30. (The fields actually have individual names, not Field1 Field2 etc.) is there a way to map my fields to an array, or do i have to have 30 internal variables? AFAIK the only way to do so is to use a custom row-reader implementation for the class. Check here for details: http://db.apache.org/ojb/docu/advanced-technique.html#using-rowreader Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping question
I'm not sure how OJB does it, but that would either mean a lot of queries, or an awful lot of outer joins! I wouldn't of thought there was a way to tell OJB to pick tables based on their foreign id. Generally you use references to exact types, or supertypes that are extended by a few classes. I think the correct way to deal with this is by using extents. I say this because in the java class that references another object, you will have to use the same approach. Lets say you have a classes A,B,C,D, etc If in A it has a reference to myFriend: as you don't know the type of myFriend (could be A, B, C, D, etc), you can only refer to something that all these classes extend (or implement). So, class A extends BaseClass { BaseClass myFriend; } and all the classes muse extend BaseClass. I'm not sure what it is you're trying to map, but I've never come across a case where you always need to refer to any class. You could use extents like this, and use this where you need to reference *any* object, but you could still reference a type directly where you know what it will be. So if you know that myFriendFKID will always be a B: class A extends BaseClass { B myFriend; } You can just use a reference descriptor in the repository referencing the type B, not the BaseClass extent. Hope this clarifies things, Daniel. > -Original Message- > From: news [mailto:[EMAIL PROTECTED] Behalf Of Sebastian > Sent: 02 June 2004 17:47 > To: [EMAIL PROTECTED] > Subject: Re: Mapping question > > > Hi Daniel, > > I had a look at the extents now. I think this will basically work. The > problem I see is, that the database has 110 tables and all are using a > globally generated OID. In my basic class I would have to list all other > classes as extents of this one. > > What does this mean for the performance of OJB? will OJB now query all > 110 tables to find the right object? > > Since I know quite easily based on the first 3 letters of the OID what > type it is, can I somehow tell that OJB as a hint to search the > right table? > > Sebastian > > Daniel Perry wrote: > > > What about using an extent and having both types extend it. It > would pick > > the right class based on whichever table has an item with that > primary key. > > > > Daniel. > > > > > >>-----Original Message- > >>From: news [mailto:[EMAIL PROTECTED] Behalf Of Sebastian > >>Sent: 02 June 2004 17:07 > >>To: [EMAIL PROTECTED] > >>Subject: Re: Mapping question > >> > >> > >>To simplify my question: > >> > >>I have a table containing a foreign key column and the foreign key of a > >>row points to different tables based on the first three letters of the > >>foreign key. E.g. when it starts with "art" then it points to a record > >>in the article table. When it starts with "cat" then it points to a > >>category table. > >> > >>This means OJB should based on the first three letters of the foreign > >>key know what kind of object to reference. > >> > >>What kind of custom mapper or converter or whatever do I have to write. > >> > >>Thanks, > >>Sebastian > >> > >> > >>Sebastian wrote: > >> > >>>Hi, > >>>I'm trying to map some tables with OJBs but don't know how to express > >>>their relation. Maybe someone can give me a hint. > >>> > >>>I have three tables: > >>>articles with OID as primary key > >>>categories with OID as primary key > >>>custom_fields with OID as primary key, OID_FK as foreign key > >>> > >>>OID is generated uniquely over all tables in a format: "first 3 letters > >>>of the table name" plus a "incrementing value". E.g. > >>>cat01,art02,art03,cus04. > >>> > >>>An article as well as a category can have a custom field that is stored > >>>in the custom_fields table, the OID_FK is the OID of the > >> > >>related article > >> > >>>or category. The first three letters of OID indicate the "object type" > >>>article or category. > >>> > >>>How do I have to configure the repository.xml so that always the right > >>>object (a category or an article) is referenced by an > >> > >>customField object? > >> > >>>Thanks in advance, > >>>Sebastian > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
Hi Daniel, I had a look at the extents now. I think this will basically work. The problem I see is, that the database has 110 tables and all are using a globally generated OID. In my basic class I would have to list all other classes as extents of this one. What does this mean for the performance of OJB? will OJB now query all 110 tables to find the right object? Since I know quite easily based on the first 3 letters of the OID what type it is, can I somehow tell that OJB as a hint to search the right table? Sebastian Daniel Perry wrote: What about using an extent and having both types extend it. It would pick the right class based on whichever table has an item with that primary key. Daniel. -Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of Sebastian Sent: 02 June 2004 17:07 To: [EMAIL PROTECTED] Subject: Re: Mapping question To simplify my question: I have a table containing a foreign key column and the foreign key of a row points to different tables based on the first three letters of the foreign key. E.g. when it starts with "art" then it points to a record in the article table. When it starts with "cat" then it points to a category table. This means OJB should based on the first three letters of the foreign key know what kind of object to reference. What kind of custom mapper or converter or whatever do I have to write. Thanks, Sebastian Sebastian wrote: Hi, I'm trying to map some tables with OJBs but don't know how to express their relation. Maybe someone can give me a hint. I have three tables: articles with OID as primary key categories with OID as primary key custom_fields with OID as primary key, OID_FK as foreign key OID is generated uniquely over all tables in a format: "first 3 letters of the table name" plus a "incrementing value". E.g. cat01,art02,art03,cus04. An article as well as a category can have a custom field that is stored in the custom_fields table, the OID_FK is the OID of the related article or category. The first three letters of OID indicate the "object type" article or category. How do I have to configure the repository.xml so that always the right object (a category or an article) is referenced by an customField object? Thanks in advance, Sebastian - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping question
What about using an extent and having both types extend it. It would pick the right class based on whichever table has an item with that primary key. Daniel. > -Original Message- > From: news [mailto:[EMAIL PROTECTED] Behalf Of Sebastian > Sent: 02 June 2004 17:07 > To: [EMAIL PROTECTED] > Subject: Re: Mapping question > > > To simplify my question: > > I have a table containing a foreign key column and the foreign key of a > row points to different tables based on the first three letters of the > foreign key. E.g. when it starts with "art" then it points to a record > in the article table. When it starts with "cat" then it points to a > category table. > > This means OJB should based on the first three letters of the foreign > key know what kind of object to reference. > > What kind of custom mapper or converter or whatever do I have to write. > > Thanks, > Sebastian > > > Sebastian wrote: > > Hi, > > I'm trying to map some tables with OJBs but don't know how to express > > their relation. Maybe someone can give me a hint. > > > > I have three tables: > > articles with OID as primary key > > categories with OID as primary key > > custom_fields with OID as primary key, OID_FK as foreign key > > > > OID is generated uniquely over all tables in a format: "first 3 letters > > of the table name" plus a "incrementing value". E.g. > > cat01,art02,art03,cus04. > > > > An article as well as a category can have a custom field that is stored > > in the custom_fields table, the OID_FK is the OID of the > related article > > or category. The first three letters of OID indicate the "object type" > > article or category. > > > > How do I have to configure the repository.xml so that always the right > > object (a category or an article) is referenced by an > customField object? > > > > Thanks in advance, > > Sebastian > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
To simplify my question: I have a table containing a foreign key column and the foreign key of a row points to different tables based on the first three letters of the foreign key. E.g. when it starts with "art" then it points to a record in the article table. When it starts with "cat" then it points to a category table. This means OJB should based on the first three letters of the foreign key know what kind of object to reference. What kind of custom mapper or converter or whatever do I have to write. Thanks, Sebastian Sebastian wrote: Hi, I'm trying to map some tables with OJBs but don't know how to express their relation. Maybe someone can give me a hint. I have three tables: articles with OID as primary key categories with OID as primary key custom_fields with OID as primary key, OID_FK as foreign key OID is generated uniquely over all tables in a format: "first 3 letters of the table name" plus a "incrementing value". E.g. cat01,art02,art03,cus04. An article as well as a category can have a custom field that is stored in the custom_fields table, the OID_FK is the OID of the related article or category. The first three letters of OID indicate the "object type" article or category. How do I have to configure the repository.xml so that always the right object (a category or an article) is referenced by an customField object? Thanks in advance, Sebastian - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping Classes on Multiple Joined Tables
hi charles, this should do it: Query q = QueryFactory.newQuery(A.class, c); broker.getCollectionByQuery(q); fyi there's a testcase dealing with multi-joined-tables InheritanceMultipleTableTest. this testcase requires the latest from repository to pass completely. hth jakob Charles N. Harvey III wrote: Hello. The other day I embarked on a little journey by mapping classes on multiple joined tables. It went really well. I am very excited to see it working and to see it working so well. One question though, and I can use the example on the site to demonstrate. Ok. So, I can now do this: Criteria c = new Criteria(); c.addEqualTo("someValueFromA", new Integer(1)); c.addEqualTo("someValueFromB", new Integer(2)); Query q = QueryFactory.newQuery(B.class, c); broker.getCollectionByQuery(q); Which is really cool. But, how can I select ONLY CLASSES FROM A? Every time I insert a B it inserts into A. And that's how it is supposed to work. But I also insert plain 'ol As into A. So how can I select a collection of ONLY A? Is this possible? I think it is but I have to do a sub query like, SELECT * FROM A WHERE NOT IN (SELECT ID FROM B) Am I correct? And, how do I do that in OJB? Thanks a lot for the help. Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping two classes two one table
The result of a report query is a Object [], where each element represents a row from the database, and is a Object[] (one value for each field returned). Best regards, Edson Richter Guido Beutler wrote: Hi jakob, Thanks for the fast reply! works fine but one shot question: How do I get the values (colums) from the object ? At the test cases I found only asserts on the size of the collection. Of course I would like to get the values. Thanks in Advance!! best regards, Guido Jakob Braeuchi wrote: hi guido, use a report-query to retrieve the pks only. hth jakob Guido Beutler wrote: Hi, I've got a small problem. I have a table with many columns. I would like to select only the primary key field with a complex select first. It's like a candidate list. From that I can find the correct value (independen from the database). For the correct value I would like to receive all data. I build two classes and mapped them to the same table. This is working fine. I got one class only with the primary key and another with all fields. I do not use inheritance, because all entries of the table have the same type (there is no third class with another type). The problem now is , that during the select for the primary key class OJB creates a select for all colums although only the primary key is needed. This is working, the primary key class is filled correctly. The the reason for building a primary key class was the performance impact of reading all coloumns. I would like to avoid reading all colums if I need only one. Is there a way to avoid reading all coulums directly? best regards, Guido - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping two classes two one table
Hi jakob, Thanks for the fast reply! works fine but one shot question: How do I get the values (colums) from the object ? At the test cases I found only asserts on the size of the collection. Of course I would like to get the values. Thanks in Advance!! best regards, Guido Jakob Braeuchi wrote: hi guido, use a report-query to retrieve the pks only. hth jakob Guido Beutler wrote: Hi, I've got a small problem. I have a table with many columns. I would like to select only the primary key field with a complex select first. It's like a candidate list. From that I can find the correct value (independen from the database). For the correct value I would like to receive all data. I build two classes and mapped them to the same table. This is working fine. I got one class only with the primary key and another with all fields. I do not use inheritance, because all entries of the table have the same type (there is no third class with another type). The problem now is , that during the select for the primary key class OJB creates a select for all colums although only the primary key is needed. This is working, the primary key class is filled correctly. The the reason for building a primary key class was the performance impact of reading all coloumns. I would like to avoid reading all colums if I need only one. Is there a way to avoid reading all coulums directly? best regards, Guido - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping two classes two one table
hi guido, use a report-query to retrieve the pks only. hth jakob Guido Beutler wrote: Hi, I've got a small problem. I have a table with many columns. I would like to select only the primary key field with a complex select first. It's like a candidate list. From that I can find the correct value (independen from the database). For the correct value I would like to receive all data. I build two classes and mapped them to the same table. This is working fine. I got one class only with the primary key and another with all fields. I do not use inheritance, because all entries of the table have the same type (there is no third class with another type). The problem now is , that during the select for the primary key class OJB creates a select for all colums although only the primary key is needed. This is working, the primary key class is filled correctly. The the reason for building a primary key class was the performance impact of reading all coloumns. I would like to avoid reading all colums if I need only one. Is there a way to avoid reading all coulums directly? best regards, Guido - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping composite collections
Heh, I must have been asleep when I wrote that, it all seems so obvious now! :-) Sorry for the noise! L. Laurie Harper wrote: I'm a bit at a loss on this one :-) I have a class whose properties are collections of entries defined by an inner class. I can see how to map the inner class onto a database table directly, but not how to either map or populate the outer class. Here's a trimmed down sample of the code I have: public class Results { public class Entry { private Race race; private Driver driver; private short result_type; // race or practice private int position; private long time; } private List practiceResults; private List raceResults; } So, mapping Results.Entry would be no problem but how do I map Results itself? I'd rather be able to materialise an instance of Results directly, rather than have to do a pair of collection queries on Results.Entry and build a Results instance from them... Am I stuck with mapping Results.Entry and managing Results instances manually or does OJB have a way to do this for me? Thanks for any suggestions! L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping Inheritance
Well, I read the documentation that there is a way to do say. But I want that when I query on Task class all objects of Task as well as Complaint should be returned, because Complaint is a sub class of Task. But document says that you cannot do so! Is there any workaround ? Thank you -Original Message- From: Muhammad Aamir Sent: Wednesday, March 03, 2004 3:08 PM To: [EMAIL PROTECTED] Subject: Mapping Inheritance How can we implement inheritance with one table for each class and tables are joined with foreign key (no duplicating columns) Thank you, Muhammad Aamir Senior Software Engineer Karachi International Container Terminal Tel: (9221) 2316401-20 Fax: (9221) 2313816 E-mail: [EMAIL PROTECTED] Website: http://www.kictl.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
My problem is that the C.foreignId field contains both a.idA and b.idB and I know if it's an A id or a B id with C.type field. The query must have "C.foreignId = A.idA AND C.type='typeA'" or "C.foreignId = B.idB AND C.type='typeB'" clause. it's not a standard case of "1:n relations". thanks Florent Surlignage [EMAIL PROTECTED]: > > > > > Hello again, > > If you want "C.foreignId = A.idA" then the 1:n - relation between C and A > is the other way round: C would be the n-class. > But if you simply want C having two collections as attributes, it is > described in tutorial 3, "mapping 1:n relations". > Was that the answer? > > regards, > Birgitta - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
Hello again, If you want "C.foreignId = A.idA" then the 1:n - relation between C and A is the other way round: C would be the n-class. But if you simply want C having two collections as attributes, it is described in tutorial 3, "mapping 1:n relations". Was that the answer? regards, Birgitta
Re: Mapping question
My english is not good ;-) What I want is in C object 2 collections one with typeA Object and one with typeB Object. My question is how to do a mapping with OJB that can make this kind of switch on type field. In other word when I load A objects collection of a C object the query is : SELECT AFields ... FROM A, C WHERE C.id=? AND C.foreignId = A.idA AND C.type="typeA" And for B objects collection : SELECT BFields ... FROM B, C WHERE C.id=? AND C.foreignId = B.idB AND C.type="typeB". regards, Florent ps : the relation to map was : Table A idA otherFields Table B idB otherFields Table C idC foreignId type otherFields Relation : C - A 1:n C - B 1:n example : A a1 ... a2 ... B b1 ... b2 ... C c1 b1 typeB ... c2 a1 typeA ... c3 b2 typeB ... Surlignage [EMAIL PROTECTED]: > > > > > > Hello Florent, > > I understand this as a question about the typeB collection or the typeA > collection exclusively in the C instance? > Then you can't even model this in UML (or so I think), so I don't think you > can in OJB. > > The only workaround I know without having two collections in C is a > relation to the class Object (or another parent of A as well as parent of > B), but actually I have huge problems with OJB in determining which is the > real child class with a relation to the parent class. > > What is so bad about having two collections in C anyway? In the setter > method you cold restrict on having only one collection filled. > > regards, > Birgitta - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
My english is not good ;-) What I want is in C object 2 collections one with typeA Object and one with typeB Object. My question is how to do a mapping with OJB that can make this kind of switch on type field. In other word when I load A objects collection of a C object the query is : SELECT AFields ... FROM A, C WHERE C.id=? AND C.foreignId = A.idA AND C.type="typeA" And for B objects collection : SELECT BFields ... FROM B, C WHERE C.id=? AND C.foreignId = B.idB AND C.type="typeB". regards, Florent ps : the relation to map was : Table A idA otherFields Table B idB otherFields Table C idC foreignId type otherFields Relation : C - A 1:n C - B 1:n example : A a1 ... a2 ... B b1 ... b2 ... C c1 b1 typeB ... c2 a1 typeA ... c3 b2 typeB ... Surlignage [EMAIL PROTECTED]: > > > > > > Hello Florent, > > I understand this as a question about the typeB collection or the typeA > collection exclusively in the C instance? > Then you can't even model this in UML (or so I think), so I don't think you > can in OJB. > > The only workaround I know without having two collections in C is a > relation to the class Object (or another parent of A as well as parent of > B), but actually I have huge problems with OJB in determining which is the > real child class with a relation to the parent class. > > What is so bad about having two collections in C anyway? In the setter > method you cold restrict on having only one collection filled. > > regards, > Birgitta - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping question
Hello Florent, I understand this as a question about the typeB collection or the typeA collection exclusively in the C instance? Then you can't even model this in UML (or so I think), so I don't think you can in OJB. The only workaround I know without having two collections in C is a relation to the class Object (or another parent of A as well as parent of B), but actually I have huge problems with OJB in determining which is the real child class with a relation to the parent class. What is so bad about having two collections in C anyway? In the setter method you cold restrict on having only one collection filled. regards, Birgitta
RE: Mapping Question
Hi Patrick. Is the field doc_id in download_pal_model actually meant to be model_id? Otherwise I am a touch confused :) Also, I assume you've checked out the advanced O/R mapping stuff at http://db.apache.org/ojb/tutorial3.html - if not, do it now! Idea #1: For download -> model ... Field Descriptors ... And going from model -> download... ... Field Descriptors ... Okay, that's a simple non-decomposed M:N and you probably know that already ... That doesn't really help with the single-collection issue at all. Idea #2: How about: ... Field Descriptors ... ... Field Descriptors ... You should be able to keep your object design the same and just modify the tables a bit so there is one table for both relations... Still non-decomposed :) #3: Implement pal_model_download and pal_model_document as classes, extending a common class (ModelContents). Then ... ... Field Descriptors ... ... Field Descriptors ... This will make the object model a bit harder, since model.collectionOfSupportItemIs will return ModelContent objects, not actual Downloads/Documents (i.e decomposed M:N) but you can keep the existing table stuff. Others may have better ideas :) Good Luck, Rob :) -Original Message- From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] Sent: Friday, 2 January 2004 2:56 p.m. To: OJB Users List Subject: Mapping Question Hi, Please see the attached image of my data model for reference (I'm sorry for the attachment but it's kind of complicated to describe the scenario otherwise. A picture says more than a thousand words :-) ). How do I map the relationship between pal_model - download and pal_model - document? The corresponding value objects (DownloadVO and DocumentVO) both implement the Interface SupportItemI. My PalModelVO has a collection which holds all the SupportItemIs for a PalModelVO. How can I map a collection that gets it's data from two m-n relationships? Can I specify two indirection tables? Do i have to change my data model? Any comments and suggestions are welcome. I wish everybody a peaceful, prosperous and happy new year! Patrick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping Question
ooops, I guess attachments are not allowed in this mailing list. here's a link to the picture: http://homepage.hispeed.ch/tabalooga/datamodel.jpg the same problem of course also exists for the keyword table. Thank you, Patrick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping problem
Hi Stephan, sorry now I'm stumped! How does your test case exactly look like? Do you create and store all used objects at the beginning of the test case to avoid reading of corrupted data? Please have a look in OJB test suite there you can find a test case called ...broker.MtoNTest (mappings can be found in repository_junit.xml), which does exactly what you want to do. regards, Armin Stephan Wannenwetsch wrote: Hallo Armin, I've changed the mapping and the code but nothing changed. I can't get the Suppliers of an Item ;-(( Mapping now: name="shippingCost" column="SHIPPINGCOST" jdbc-type="INTEGER"/> name="businessPartner" class-ref="demo.myshop.model.ojb2.BusinessPartner"> name="items" element-class-ref="demo.myshop.model.ojb2.SellableItem" auto-retrieve="true" auto-update="true" indirection-table="OJB_SUPPLIER_ITEM"> I hope you have some more ideas. Thanks, Stephan -Original Message----- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 4:57 PM To: OJB Users List Subject: Re: Mapping problem Hi Stephan, Stephan Wannenwetsch wrote: Hallo Armin, the insert error has gone, but now I have again the problem with recieving the suppliers from an item. I mean something like that: Mapping changed to: add new field for PK of Supplier ==> name="supId" > column="SUP_ID" > jdbc-type="INTEGER" > primarykey="true" ==> autoincrement="true"/> let the FK field to BusinessPartner be anonymous jdbc-type="INTEGER" <== primarykey="true" ==> primarykey="false" ==> access="anonymous" autoincrement="false"/> name="shippingCost" column="SHIPPINGCOST" jdbc-type="INTEGER"/> name="businessPartner" class-ref="demo.myshop.model.ojb2.BusinessPartner"> name="items" element-class-ref="demo.myshop.model.ojb2.SellableItem" auto-retrieve="true" auto-update="true" indirection-table="OJB_SUPPLIER_ITEM"> I also added the fk-bpid field to the Supplier.class + getters/setters setter+getter are only necessary if you want to use a PersistentField implementation which use bean compliant method access. regards, Armin SellableItem: package demo.myshop.model.ojb2; import java.util.Collection; public interface SellableItem { public String getDescription(); public Integer getItemId(); public Integer getPrice(); public void setDescription(String description); public void setPrice(Integer price); public Collection getSuppliers(); public void setSuppliers(Collection supplier); public void addSupplier(Supplier supplier); public String getConcreteClass(); public String getOjbConcreteClass(); public void setOjbConcreteClass(String ojbConcreteClass); } Implemented for example in Service Contract: package demo.myshop.model.ojb2; import java.util.Collection; import java.util.HashSet; public class ServiceContract implements SellableItem { private Integer itemId; protected String ojbConcreteClass; private String description; private Integer price; private Integer period; private Collection suppliers; public ServiceContract() { ojbConcreteClass = ServiceContract.class.getName(); suppliers = new HashSet(); } public String getDescription() { return description; } public Integer getItemId() { return itemId; } public Integer getPeriod() { return period; } public Integer getPrice() { return price; } public void setDescription(String description) { this.description = description; } public void setPeriod(Integer period) { this.period = period; } public void setPrice(Integer price) { this.price = price; } public Collection getSuppliers() { return suppliers; } public void setSuppliers(Collection suppliers) { this.suppliers = suppliers; } public void addSuppl
RE: Mapping problem
Hallo Armin, I've changed the mapping and the code but nothing changed. I can't get the Suppliers of an Item ;-(( Mapping now: I hope you have some more ideas. Thanks, Stephan -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 4:57 PM To: OJB Users List Subject: Re: Mapping problem Hi Stephan, Stephan Wannenwetsch wrote: > Hallo Armin, > > the insert error has gone, but now I have again the problem with > recieving the suppliers from an item. > I mean something like that: > Mapping changed to: > class="demo.myshop.model.ojb2.Supplier" > table="OJB_SUPPLIER"> add new field for PK of Supplier ==> name="supId" > column="SUP_ID" > jdbc-type="INTEGER" > primarykey="true" ==> autoincrement="true"/> let the FK field to BusinessPartner be anonymous > name="fk_bpid" > column="FK_BPID" jdbc-type="INTEGER" <== primarykey="true" ==> primarykey="false" ==> access="anonymous" autoincrement="false"/> > > name="shippingCost" > column="SHIPPINGCOST" > jdbc-type="INTEGER"/> > > name="businessPartner" > class-ref="demo.myshop.model.ojb2.BusinessPartner"> > > > > name="items" > element-class-ref="demo.myshop.model.ojb2.SellableItem" > auto-retrieve="true" > auto-update="true" > indirection-table="OJB_SUPPLIER_ITEM"> > > > > > > > I also added the fk-bpid field to the Supplier.class + getters/setters > setter+getter are only necessary if you want to use a PersistentField implementation which use bean compliant method access. regards, Armin > SellableItem: > > package demo.myshop.model.ojb2; > > import java.util.Collection; > > public interface SellableItem { > > public String getDescription(); > > public Integer getItemId(); > > public Integer getPrice(); > > public void setDescription(String description); > > public void setPrice(Integer price); > > public Collection getSuppliers(); > > public void setSuppliers(Collection supplier); > > public void addSupplier(Supplier supplier); > > public String getConcreteClass(); > > public String getOjbConcreteClass(); > > public void setOjbConcreteClass(String ojbConcreteClass); > } > > Implemented for example in Service Contract: > > package demo.myshop.model.ojb2; > import java.util.Collection; > import java.util.HashSet; > > public class ServiceContract implements SellableItem { > > private Integer itemId; > protected String ojbConcreteClass; > private String description; > private Integer price; > private Integer period; > private Collection suppliers; > > public ServiceContract() { > ojbConcreteClass = ServiceContract.class.getName(); > suppliers = new HashSet(); > } > > public String getDescription() { > return description; > } > > public Integer getItemId() { > return itemId; > } > > public Integer getPeriod() { > return period; > } > > public Integer getPrice() { > return price; > } > > public void setDescription(String description) { > this.description = description; > } > > public void setPeriod(Integer period) { > this.period = period; > } > > public void setPrice(Integer price) { > this.price = price; > } > > > public Collection getSuppliers() { > return suppliers; > } > > public void setSuppliers(Collection suppliers) { > this.suppliers = suppliers; > } > > public void addSupplier(Supplier supplier){ >
Re: Mapping problem
"); //for debug only while (iter6.hasNext()){ ServiceContract item6 = (ServiceContract) iter6.next(); System.out.println("Item:" + item6.getDescription() +" " + item6.getPrice()); //for debug only Iterator iter7 = item6.getSuppliers().iterator(); if (iter7.hasNext() == false) System.out.println("Item count = 0"); //for debug only else System.out.println("Item count > 0"); //for debug only while (iter7.hasNext()){ Supplier sup7 = (Supplier) iter7.next(); System.out.println("Supplier of Item:" + sup7.getBusinessPartner().getName() + " " + sup7.getShippingCosts()); //for debug only } } broker.close(); System.out.println("Brooker closed"); //for debug only Debug message output: Cache cleared Criterias created Query executed Iterator received Item count > 0 Item:SC2 200 Item count = 0 <== SHOULDN'T BE 0 Brooker closed Test succeded Testdata OJB_ITEM: ITEMID CLASS_NAME DESCRIPTION PRICE PERIOD WEIGHT 21 demo.myshop.model.ojb2.Product P1 100 1000 22 demo.myshop.model.ojb2.Product P2 200 2000 23 demo.myshop.model.ojb2.ServiceContract SC2 200 20 24 demo.myshop.model.ojb2.ServiceContract SC1 100 10 OJB_SUPPLIER: FK_BPID SHIPPINGCOST 25 120 26 130 OJB_SUPPLIER_ITEM: ITEMID SUPPLIERID 21 25 22 25 22 26 23 25 23 26 24 25 I hope you can find my error ;-) Thanks, Stephan -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 11:13 AM To: OJB Users List Subject: Re: Mapping problem Hi again, Stephan Wannenwetsch wrote: Hallo Armin, 1) Nothing changed in mapping for Supplier 2) "fk_bpid" is the primary key for this class/table, but it is also the foreign key of the 1:1 relationship to BusinessPartner I think this is problematic, because the pc object does not declare such a field (you set to anonymous). OJB try to build a Identity object for each pc object based on the PK fields and the only primarykey field in Supplier is declared anonymous ... Recommend to introduce a PK field for Supplier and set primarykey false for fk_bpid. 3) I'm not quite sure if I have to declare a field-descriptor for "SUPPLIERID", because in the docs ("Advanced O/R") nothing is mentioned. yes, you are right - my fault. I'm not an expert for metadata stuff ;-) 4) The SQL-Error occures just after I had changed the mapping of SellableItem, Product, ServiceContract as Wally said, before insert was not the problem. So perhaps the mapping of the Products is the problem !? But the mapping for these classes looks fine to me. regards, Armin Thanks, Stephan -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 10:29 AM To: OJB Users List Subject: Re: Mapping problem Hi Stephan, hmm, how does your mapping for demo.myshop.model.ojb2.Supplier look like (nothing changed from your first post)? From your first post >> >class="demo.myshop.model.ojb2.Supplier" >>table="OJB_SUPPLIER"> >>>name="fk_bpid" >>column="FK_BPID" >>jdbc-type="INTEGER" >>primarykey="true" Why you set primarykey 'true' for this anonymous field? >>autoincrement="false" >>access="anonymous"/> >> >>>name="shippingCost" >>column="SHIPPINGCOST" >>jdbc-type="INTEGER"/> >> >>>name="businessPartner" >>class-ref="demo.myshop.model.ojb2.BusinessPartner"> >> >> >> >>>name="items" >>element-class-ref="demo.myshop.model.ojb2.SellableItem" >>auto-retrieve="true" >>auto-update="true" >>indirection-table="OJB_S
RE: Mapping problem
eated Query executed Iterator received Item count > 0 Item:SC2 200 Item count = 0 <== SHOULDN'T BE 0 Brooker closed Test succeded Testdata OJB_ITEM: ITEMID CLASS_NAME DESCRIPTION PRICE PERIOD WEIGHT 21 demo.myshop.model.ojb2.Product P1 100 1000 22 demo.myshop.model.ojb2.Product P2 200 2000 23 demo.myshop.model.ojb2.ServiceContract SC2 200 20 24 demo.myshop.model.ojb2.ServiceContract SC1 100 10 OJB_SUPPLIER: FK_BPID SHIPPINGCOST 25 120 26 130 OJB_SUPPLIER_ITEM: ITEMID SUPPLIERID 21 25 22 25 22 26 23 25 23 26 24 25 I hope you can find my error ;-) Thanks, Stephan -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 11:13 AM To: OJB Users List Subject: Re: Mapping problem Hi again, Stephan Wannenwetsch wrote: > Hallo Armin, > > 1) Nothing changed in mapping for Supplier > 2) "fk_bpid" is the primary key for this class/table, but it is also > the foreign key of the 1:1 relationship to BusinessPartner I think this is problematic, because the pc object does not declare such a field (you set to anonymous). OJB try to build a Identity object for each pc object based on the PK fields and the only primarykey field in Supplier is declared anonymous ... Recommend to introduce a PK field for Supplier and set primarykey false for fk_bpid. > 3) I'm not quite sure if I have to declare a field-descriptor for > "SUPPLIERID", because in the docs ("Advanced O/R") nothing is > mentioned. yes, you are right - my fault. I'm not an expert for metadata stuff ;-) > 4) The SQL-Error occures just after I had changed the mapping of > SellableItem, Product, ServiceContract as Wally said, before insert > was not the problem. So perhaps the mapping of the Products is the > problem !? > But the mapping for these classes looks fine to me. regards, Armin > Thanks, > > Stephan > > -Original Message- > From: Armin Waibel [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 17, 2003 10:29 AM > To: OJB Users List > Subject: Re: Mapping problem > > > Hi Stephan, > > hmm, how does your mapping for demo.myshop.model.ojb2.Supplier > look like (nothing changed from your first post)? > > From your first post > > >>>> class="demo.myshop.model.ojb2.Supplier" > >> table="OJB_SUPPLIER"> > >> >> name="fk_bpid" > >> column="FK_BPID" > >> jdbc-type="INTEGER" > >> primarykey="true" > > Why you set primarykey 'true' for this anonymous field? > > >> autoincrement="false" > >> access="anonymous"/> > >> > >> >> name="shippingCost" > >> column="SHIPPINGCOST" > >> jdbc-type="INTEGER"/> > >> > >> >> name="businessPartner" > >> class-ref="demo.myshop.model.ojb2.BusinessPartner"> > >> > >> > >> > >> >> name="items" > >> element-class-ref="demo.myshop.model.ojb2.SellableItem" > >> auto-retrieve="true" > >> auto-update="true" > >> indirection-table="OJB_SUPPLIER_ITEM"> > >> > > Can't see a field-descriptor with SUPPLIERID column in this > class-descriptor. > > >> > >> > >> > >> > > regards, > Armin > > Stephan Wannenwetsch wrote: > >>Hi Armin, >> >>I checked it but nothing changed. I also removed all data from the >>DB-tables but nothing changed, too. >> >>Thanks, >>Stephan >> >>-Original Message- >>From: Armin Waibel [mailto:[EMAIL PROTECTED] >>Sent: Monday, December 15, 2003 6:03 PM >>To: OJB Users List >>Subject: Re: Mapping problem >> >> >>Hi, >> >>maybe sequence-name "algorithm" had problems. Try to remove related >>row in OJB_HL_SEQ table (name of the first
Re: Mapping problem
Hi again, Stephan Wannenwetsch wrote: Hallo Armin, 1) Nothing changed in mapping for Supplier 2) "fk_bpid" is the primary key for this class/table, but it is also the foreign key of the 1:1 relationship to BusinessPartner I think this is problematic, because the pc object does not declare such a field (you set to anonymous). OJB try to build a Identity object for each pc object based on the PK fields and the only primarykey field in Supplier is declared anonymous ... Recommend to introduce a PK field for Supplier and set primarykey false for fk_bpid. 3) I'm not quite sure if I have to declare a field-descriptor for "SUPPLIERID", because in the docs ("Advanced O/R") nothing is mentioned. yes, you are right - my fault. I'm not an expert for metadata stuff ;-) 4) The SQL-Error occures just after I had changed the mapping of SellableItem, Product, ServiceContract as Wally said, before insert was not the problem. So perhaps the mapping of the Products is the problem !? But the mapping for these classes looks fine to me. regards, Armin Thanks, Stephan -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 10:29 AM To: OJB Users List Subject: Re: Mapping problem Hi Stephan, hmm, how does your mapping for demo.myshop.model.ojb2.Supplier look like (nothing changed from your first post)? From your first post >> > class="demo.myshop.model.ojb2.Supplier" >> table="OJB_SUPPLIER"> >> > name="fk_bpid" >> column="FK_BPID" >> jdbc-type="INTEGER" >> primarykey="true" Why you set primarykey 'true' for this anonymous field? >> autoincrement="false" >> access="anonymous"/> >> >> > name="shippingCost" >> column="SHIPPINGCOST" >> jdbc-type="INTEGER"/> >> >> > name="businessPartner" >> class-ref="demo.myshop.model.ojb2.BusinessPartner"> >> >> >> >> > name="items" >> element-class-ref="demo.myshop.model.ojb2.SellableItem" >> auto-retrieve="true" >> auto-update="true" >> indirection-table="OJB_SUPPLIER_ITEM"> >> Can't see a field-descriptor with SUPPLIERID column in this class-descriptor. >> >> >> >> regards, Armin Stephan Wannenwetsch wrote: Hi Armin, I checked it but nothing changed. I also removed all data from the DB-tables but nothing changed, too. Thanks, Stephan -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 6:03 PM To: OJB Users List Subject: Re: Mapping problem Hi, maybe sequence-name "algorithm" had problems. Try to remove related row in OJB_HL_SEQ table (name of the first found extent class table name). You can do a quick check using SequenceManagerInMemoryImpl in your test. If your test pass, it's a H/L sequence manager problem. regards, Armin Stephan Wannenwetsch wrote: Hi Wally, I'm using the following sequence-manager: Stephan -Original Message- From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 5:35 PM To: OJB Users List Subject: RE: Mapping problem Hi Stephan, Sounds like a sequence manager configuration problem. A PK must be unique within an extent hierarchy, so you cannot use an IDENTITY column for a PK. What sequence manager are you using? Wally -Original Message- From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 10:16 AM To: OJB Users List Subject: RE: Mapping problem Hallo Wally, I've changed the mapping into: name="suppliers" element-class-ref="demo.myshop.model.ojb2.Supplier" auto-retrieve="true" auto-update="true" indirection-table="OJB_SUPPLIER_ITEM"> class="demo.myshop.model.ojb2.Product" table="OJB_SELLABLEITEM"> name="itemId" column="ITEMID" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> name="ojbConcreteClass"
RE: Mapping problem
Hallo Armin, 1) Nothing changed in mapping for Supplier 2) "fk_bpid" is the primary key for this class/table, but it is also the foreign key of the 1:1 relationship to BusinessPartner 3) I'm not quite sure if I have to declare a field-descriptor for "SUPPLIERID", because in the docs ("Advanced O/R") nothing is mentioned. 4) The SQL-Error occures just after I had changed the mapping of SellableItem, Product, ServiceContract as Wally said, before insert was not the problem. So perhaps the mapping of the Products is the problem !? Thanks, Stephan -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 10:29 AM To: OJB Users List Subject: Re: Mapping problem Hi Stephan, hmm, how does your mapping for demo.myshop.model.ojb2.Supplier look like (nothing changed from your first post)? From your first post >> > class="demo.myshop.model.ojb2.Supplier" >> table="OJB_SUPPLIER"> >> > name="fk_bpid" >> column="FK_BPID" >> jdbc-type="INTEGER" >> primarykey="true" Why you set primarykey 'true' for this anonymous field? >> autoincrement="false" >> access="anonymous"/> >> >> > name="shippingCost" >> column="SHIPPINGCOST" >> jdbc-type="INTEGER"/> >> >> > name="businessPartner" >> class-ref="demo.myshop.model.ojb2.BusinessPartner"> >> >> >> >> > name="items" >> element-class-ref="demo.myshop.model.ojb2.SellableItem" >> auto-retrieve="true" >> auto-update="true" >> indirection-table="OJB_SUPPLIER_ITEM"> >> Can't see a field-descriptor with SUPPLIERID column in this class-descriptor. >> >> >> >> regards, Armin Stephan Wannenwetsch wrote: > Hi Armin, > > I checked it but nothing changed. I also removed all data from the > DB-tables but nothing changed, too. > > Thanks, > Stephan > > -Original Message- > From: Armin Waibel [mailto:[EMAIL PROTECTED] > Sent: Monday, December 15, 2003 6:03 PM > To: OJB Users List > Subject: Re: Mapping problem > > > Hi, > > maybe sequence-name "algorithm" had problems. Try to remove related > row in OJB_HL_SEQ table (name of the first found extent class table name). You can > do a quick check using SequenceManagerInMemoryImpl in your test. > If your test pass, it's a H/L sequence manager problem. > > regards, > Armin > > Stephan Wannenwetsch wrote: > >>Hi Wally, >> >>I'm using the following sequence-manager: >> >>>className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"> >> >> >> >> >attribute-value="10000"/> >> >>Stephan >> >> >>-Original Message- >>From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] >>Sent: Monday, December 15, 2003 5:35 PM >>To: OJB Users List >>Subject: RE: Mapping problem >> >> >>Hi Stephan, >> >>Sounds like a sequence manager configuration problem. A PK must be >>unique within an extent hierarchy, so you cannot use an IDENTITY >>column for a PK. What sequence manager are you using? >> >>Wally >> >> >> >>-Original Message- >>From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] >>Sent: Monday, December 15, 2003 10:16 AM >>To: OJB Users List >>Subject: RE: Mapping problem >> >> >>Hallo Wally, >> >>I've changed the mapping into: >> >> >> >> >> >> > class="demo.myshop.model.ojb2.ServiceContract" >> table="OJB_SELLABLEITEM"> >> >> > name="itemId" >> column="ITEMID" >> jdbc-type="INTEGER" >> primarykey="true" >> autoincrement="true"/> >> >> > name="ojbConcreteClass" >> column="CLASS_NAME" >> jdbc-type="VA
Re: Mapping problem
Hi Stephan, hmm, how does your mapping for demo.myshop.model.ojb2.Supplier look like (nothing changed from your first post)? From your first post >> >class="demo.myshop.model.ojb2.Supplier" >>table="OJB_SUPPLIER"> >>>name="fk_bpid" >>column="FK_BPID" >>jdbc-type="INTEGER" >>primarykey="true" Why you set primarykey 'true' for this anonymous field? >>autoincrement="false" >>access="anonymous"/> >> >>>name="shippingCost" >>column="SHIPPINGCOST" >>jdbc-type="INTEGER"/> >> >>>name="businessPartner" >>class-ref="demo.myshop.model.ojb2.BusinessPartner"> >> >> >> >>>name="items" >>element-class-ref="demo.myshop.model.ojb2.SellableItem" >>auto-retrieve="true" >>auto-update="true" >>indirection-table="OJB_SUPPLIER_ITEM"> >> Can't see a field-descriptor with SUPPLIERID column in this class-descriptor. >> >> >> >> regards, Armin Stephan Wannenwetsch wrote: Hi Armin, I checked it but nothing changed. I also removed all data from the DB-tables but nothing changed, too. Thanks, Stephan -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 6:03 PM To: OJB Users List Subject: Re: Mapping problem Hi, maybe sequence-name "algorithm" had problems. Try to remove related row in OJB_HL_SEQ table (name of the first found extent class table name). You can do a quick check using SequenceManagerInMemoryImpl in your test. If your test pass, it's a H/L sequence manager problem. regards, Armin Stephan Wannenwetsch wrote: Hi Wally, I'm using the following sequence-manager: Stephan -Original Message- From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 5:35 PM To: OJB Users List Subject: RE: Mapping problem Hi Stephan, Sounds like a sequence manager configuration problem. A PK must be unique within an extent hierarchy, so you cannot use an IDENTITY column for a PK. What sequence manager are you using? Wally -Original Message- From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 10:16 AM To: OJB Users List Subject: RE: Mapping problem Hallo Wally, I've changed the mapping into: name="suppliers" element-class-ref="demo.myshop.model.ojb2.Supplier" auto-retrieve="true" auto-update="true" indirection-table="OJB_SUPPLIER_ITEM"> class="demo.myshop.model.ojb2.Product" table="OJB_SELLABLEITEM"> name="itemId" column="ITEMID" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> name="ojbConcreteClass" column="CLASS_NAME" jdbc-type="VARCHAR"/> name="description" column="DESCRIPTION" jdbc-type="VARCHAR"/> name="price" column="PRICE" jdbc-type="INTEGER"/> name="weight" column="WEIGHT" jdbc-type="INTEGER"/> name="suppliers" element-class-ref="demo.myshop.model.ojb2.Supplier" auto-retrieve="true" auto-update="true" indirection-table="OJB_SUPPLIER_ITEM"> But now I get an error when I store a supplier (primary key - error, pk not unique in OJB_SUPPLIER_ITEM, can't insert). Transaction started [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException during the execution of the Update SQL query (for a demo.myshop.model.ojb2.Supplier): [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. [Microsoft][SQLServer 2000 Driv
RE: Mapping problem
Hi Armin, I checked it but nothing changed. I also removed all data from the DB-tables but nothing changed, too. Thanks, Stephan -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 6:03 PM To: OJB Users List Subject: Re: Mapping problem Hi, maybe sequence-name "algorithm" had problems. Try to remove related row in OJB_HL_SEQ table (name of the first found extent class table name). You can do a quick check using SequenceManagerInMemoryImpl in your test. If your test pass, it's a H/L sequence manager problem. regards, Armin Stephan Wannenwetsch wrote: > Hi Wally, > > I'm using the following sequence-manager: > > className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"> > > > > attribute-value="1"/> > > Stephan > > > -Original Message- > From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] > Sent: Monday, December 15, 2003 5:35 PM > To: OJB Users List > Subject: RE: Mapping problem > > > Hi Stephan, > > Sounds like a sequence manager configuration problem. A PK must be > unique within an extent hierarchy, so you cannot use an IDENTITY > column for a PK. What sequence manager are you using? > > Wally > > > > -Original Message- > From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] > Sent: Monday, December 15, 2003 10:16 AM > To: OJB Users List > Subject: RE: Mapping problem > > > Hallo Wally, > > I've changed the mapping into: > > > > > > class="demo.myshop.model.ojb2.ServiceContract" > table="OJB_SELLABLEITEM"> > > name="itemId" > column="ITEMID" > jdbc-type="INTEGER" > primarykey="true" > autoincrement="true"/> > > name="ojbConcreteClass" > column="CLASS_NAME" > jdbc-type="VARCHAR"/> > > name="description" > column="DESCRIPTION" > jdbc-type="VARCHAR"/> > > name="price" > column="PRICE" > jdbc-type="INTEGER"/> > > name="period" > column="PERIOD" > jdbc-type="INTEGER"/> > > name="suppliers" > element-class-ref="demo.myshop.model.ojb2.Supplier" > auto-retrieve="true" > auto-update="true" > indirection-table="OJB_SUPPLIER_ITEM"> > > > > > > class="demo.myshop.model.ojb2.Product" > table="OJB_SELLABLEITEM"> > > name="itemId" > column="ITEMID" > jdbc-type="INTEGER" > primarykey="true" > autoincrement="true"/> > > name="ojbConcreteClass" > column="CLASS_NAME" > jdbc-type="VARCHAR"/> > > name="description" > column="DESCRIPTION" > jdbc-type="VARCHAR"/> > > name="price" > column="PRICE" > jdbc-type="INTEGER"/> > > name="weight" > column="WEIGHT" > jdbc-type="INTEGER"/> > name="suppliers" > element-class-ref="demo.myshop.model.ojb2.Supplier" > auto-retrieve="true" > auto-update="true" > indirection-table="OJB_SUPPLIER_ITEM"> > > > > > > > > But now I get an error when I store a supplier (primary key - error, > pk not unique in OJB_SUPPLIER_ITEM, can't insert). Transaction started > > > [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException > during the execution of the Update SQL query (for a > demo.myshop.model.ojb2.Supplier): [Microsoft][S
RE: Mapping problem
Hi Armin, I checked it but nothing changed. I also removed all data from the DB-tables but nothing changed, too. Thanks, Stephan -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 6:03 PM To: OJB Users List Subject: Re: Mapping problem Hi, maybe sequence-name "algorithm" had problems. Try to remove related row in OJB_HL_SEQ table (name of the first found extent class table name). You can do a quick check using SequenceManagerInMemoryImpl in your test. If your test pass, it's a H/L sequence manager problem. regards, Armin Stephan Wannenwetsch wrote: > Hi Wally, > > I'm using the following sequence-manager: > > className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"> > > > > attribute-value="1"/> > > Stephan > > > -Original Message- > From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] > Sent: Monday, December 15, 2003 5:35 PM > To: OJB Users List > Subject: RE: Mapping problem > > > Hi Stephan, > > Sounds like a sequence manager configuration problem. A PK must be > unique within an extent hierarchy, so you cannot use an IDENTITY > column for a PK. What sequence manager are you using? > > Wally > > > > -Original Message- > From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] > Sent: Monday, December 15, 2003 10:16 AM > To: OJB Users List > Subject: RE: Mapping problem > > > Hallo Wally, > > I've changed the mapping into: > > > > > > class="demo.myshop.model.ojb2.ServiceContract" > table="OJB_SELLABLEITEM"> > > name="itemId" > column="ITEMID" > jdbc-type="INTEGER" > primarykey="true" > autoincrement="true"/> > > name="ojbConcreteClass" > column="CLASS_NAME" > jdbc-type="VARCHAR"/> > > name="description" > column="DESCRIPTION" > jdbc-type="VARCHAR"/> > > name="price" > column="PRICE" > jdbc-type="INTEGER"/> > > name="period" > column="PERIOD" > jdbc-type="INTEGER"/> > > name="suppliers" > element-class-ref="demo.myshop.model.ojb2.Supplier" > auto-retrieve="true" > auto-update="true" > indirection-table="OJB_SUPPLIER_ITEM"> > > > > > > class="demo.myshop.model.ojb2.Product" > table="OJB_SELLABLEITEM"> > > name="itemId" > column="ITEMID" > jdbc-type="INTEGER" > primarykey="true" > autoincrement="true"/> > > name="ojbConcreteClass" > column="CLASS_NAME" > jdbc-type="VARCHAR"/> > > name="description" > column="DESCRIPTION" > jdbc-type="VARCHAR"/> > > name="price" > column="PRICE" > jdbc-type="INTEGER"/> > > name="weight" > column="WEIGHT" > jdbc-type="INTEGER"/> > name="suppliers" > element-class-ref="demo.myshop.model.ojb2.Supplier" > auto-retrieve="true" > auto-update="true" > indirection-table="OJB_SUPPLIER_ITEM"> > > > > > > > > But now I get an error when I store a supplier (primary key - error, > pk not unique in OJB_SUPPLIER_ITEM, can't insert). Transaction started > > > [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException > during the execution of the Update SQL query (for a > demo.myshop.model.ojb2.Supplier): [Microsoft][S
Re: Mapping problem
Hi, maybe sequence-name "algorithm" had problems. Try to remove related row in OJB_HL_SEQ table (name of the first found extent class table name). You can do a quick check using SequenceManagerInMemoryImpl in your test. If your test pass, it's a H/L sequence manager problem. regards, Armin Stephan Wannenwetsch wrote: Hi Wally, I'm using the following sequence-manager: Stephan -Original Message- From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 5:35 PM To: OJB Users List Subject: RE: Mapping problem Hi Stephan, Sounds like a sequence manager configuration problem. A PK must be unique within an extent hierarchy, so you cannot use an IDENTITY column for a PK. What sequence manager are you using? Wally -Original Message- From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 10:16 AM To: OJB Users List Subject: RE: Mapping problem Hallo Wally, I've changed the mapping into: name="suppliers" element-class-ref="demo.myshop.model.ojb2.Supplier" auto-retrieve="true" auto-update="true" indirection-table="OJB_SUPPLIER_ITEM"> class="demo.myshop.model.ojb2.Product" table="OJB_SELLABLEITEM"> name="itemId" column="ITEMID" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> name="ojbConcreteClass" column="CLASS_NAME" jdbc-type="VARCHAR"/> name="description" column="DESCRIPTION" jdbc-type="VARCHAR"/> name="price" column="PRICE" jdbc-type="INTEGER"/> name="weight" column="WEIGHT" jdbc-type="INTEGER"/> name="suppliers" element-class-ref="demo.myshop.model.ojb2.Supplier" auto-retrieve="true" auto-update="true" indirection-table="OJB_SUPPLIER_ITEM"> But now I get an error when I store a supplier (primary key - error, pk not unique in OJB_SUPPLIER_ITEM, can't insert). Transaction started [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException during the execution of the Update SQL query (for a demo.myshop.model.ojb2.Supplier): [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann i n das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) Some more ideas ??? Thanks, Stephan -Original Message- From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 3:44 PM To: OJB Users List Subject: RE: Mapping problem Hi Stephan, OJB does not support class descriptor inheritance for elements. Try moving your "common" fields from Sellable item into each of the concrete class descriptors and making Sellable item non-concrete (it is only an interface after all) such as: Hope this helps. Wally -Original Message- From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 4:16 AM To: [EMAIL PROTECTED] Subject: Mapping problem Hallo, I've got a problem retrieving objects from a m:n relationship: Object model: class Supplier; =>Collection items; Interface SellableItem; =>Collection suppliers; class Product implements SellableItem; => Collection suppliers; class ServiceContract implements SellableItem; => Collection suppliers; Of course there are some more attributes in each class with the corresponding getter and setters. I use an itermediate table OJB_SUPPLIER_ITEM to realise the m:n relationship. Every thing works fine coming from the supplier side and retriving the related items of a supplier but I&
RE: Mapping problem
Hi Wally, I'm using the following sequence-manager: Stephan -Original Message- From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 5:35 PM To: OJB Users List Subject: RE: Mapping problem Hi Stephan, Sounds like a sequence manager configuration problem. A PK must be unique within an extent hierarchy, so you cannot use an IDENTITY column for a PK. What sequence manager are you using? Wally -Original Message- From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 10:16 AM To: OJB Users List Subject: RE: Mapping problem Hallo Wally, I've changed the mapping into: But now I get an error when I store a supplier (primary key - error, pk not unique in OJB_SUPPLIER_ITEM, can't insert). Transaction started [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException during the execution of the Update SQL query (for a demo.myshop.model.ojb2.Supplier): [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann i n das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) Some more ideas ??? Thanks, Stephan -Original Message- From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 3:44 PM To: OJB Users List Subject: RE: Mapping problem Hi Stephan, OJB does not support class descriptor inheritance for elements. Try moving your "common" fields from Sellable item into each of the concrete class descriptors and making Sellable item non-concrete (it is only an interface after all) such as: Hope this helps. Wally -Original Message- From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 4:16 AM To: [EMAIL PROTECTED] Subject: Mapping problem Hallo, I've got a problem retrieving objects from a m:n relationship: Object model: class Supplier; =>Collection items; Interface SellableItem; =>Collection suppliers; class Product implements SellableItem; => Collection suppliers; class ServiceContract implements SellableItem; => Collection suppliers; Of course there are some more attributes in each class with the corresponding getter and setters. I use an itermediate table OJB_SUPPLIER_ITEM to realise the m:n relationship. Every thing works fine coming from the supplier side and retriving the related items of a supplier but I'm not able to retrieve the related suppliers of an item. I hope someone can help me. Thanks, Stephan Mapping: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --
RE: Mapping problem
Hi Stephan, Sounds like a sequence manager configuration problem. A PK must be unique within an extent hierarchy, so you cannot use an IDENTITY column for a PK. What sequence manager are you using? Wally -Original Message- From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 10:16 AM To: OJB Users List Subject: RE: Mapping problem Hallo Wally, I've changed the mapping into: But now I get an error when I store a supplier (primary key - error, pk not unique in OJB_SUPPLIER_ITEM, can't insert). Transaction started [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException during the execution of the Update SQL query (for a demo.myshop.model.ojb2.Supplier): [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) Some more ideas ??? Thanks, Stephan -Original Message- From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 3:44 PM To: OJB Users List Subject: RE: Mapping problem Hi Stephan, OJB does not support class descriptor inheritance for elements. Try moving your "common" fields from Sellable item into each of the concrete class descriptors and making Sellable item non-concrete (it is only an interface after all) such as: Hope this helps. Wally -Original Message- From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 4:16 AM To: [EMAIL PROTECTED] Subject: Mapping problem Hallo, I've got a problem retrieving objects from a m:n relationship: Object model: class Supplier; =>Collection items; Interface SellableItem; =>Collection suppliers; class Product implements SellableItem; => Collection suppliers; class ServiceContract implements SellableItem; => Collection suppliers; Of course there are some more attributes in each class with the corresponding getter and setters. I use an itermediate table OJB_SUPPLIER_ITEM to realise the m:n relationship. Every thing works fine coming from the supplier side and retriving the related items of a supplier but I'm not able to retrieve the related suppliers of an item. I hope someone can help me. Thanks, Stephan Mapping: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping problem
Hallo Wally, I've changed the mapping into: But now I get an error when I store a supplier (primary key - error, pk not unique in OJB_SUPPLIER_ITEM, can't insert). Transaction started [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException during the execution of the Update SQL query (for a demo.myshop.model.ojb2.Supplier): [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschränkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schlüssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingefügt werden. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) Some more ideas ??? Thanks, Stephan -Original Message- From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 3:44 PM To: OJB Users List Subject: RE: Mapping problem Hi Stephan, OJB does not support class descriptor inheritance for elements. Try moving your "common" fields from Sellable item into each of the concrete class descriptors and making Sellable item non-concrete (it is only an interface after all) such as: Hope this helps. Wally -Original Message- From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 4:16 AM To: [EMAIL PROTECTED] Subject: Mapping problem Hallo, I've got a problem retrieving objects from a m:n relationship: Object model: class Supplier; =>Collection items; Interface SellableItem; =>Collection suppliers; class Product implements SellableItem; => Collection suppliers; class ServiceContract implements SellableItem; => Collection suppliers; Of course there are some more attributes in each class with the corresponding getter and setters. I use an itermediate table OJB_SUPPLIER_ITEM to realise the m:n relationship. Every thing works fine coming from the supplier side and retriving the related items of a supplier but I'm not able to retrieve the related suppliers of an item. I hope someone can help me. Thanks, Stephan Mapping: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping problem
You could make your life a bit easier and try out the XDoclet OJB module which automatically handles inherited fields/references/collections. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping problem
Hi Stephan, OJB does not support class descriptor inheritance for elements. Try moving your "common" fields from Sellable item into each of the concrete class descriptors and making Sellable item non-concrete (it is only an interface after all) such as: Hope this helps. Wally -Original Message- From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 4:16 AM To: [EMAIL PROTECTED] Subject: Mapping problem Hallo, I've got a problem retrieving objects from a m:n relationship: Object model: class Supplier; =>Collection items; Interface SellableItem; =>Collection suppliers; class Product implements SellableItem; => Collection suppliers; class ServiceContract implements SellableItem; => Collection suppliers; Of course there are some more attributes in each class with the corresponding getter and setters. I use an itermediate table OJB_SUPPLIER_ITEM to realise the m:n relationship. Every thing works fine coming from the supplier side and retriving the related items of a supplier but I'm not able to retrieve the related suppliers of an item. I hope someone can help me. Thanks, Stephan Mapping: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping M:N relation WITH ATTRIBUTES
M:N mapping can be done using a indirection table to store relational information. In that case OJB uses a class called MtoNImplementor that holds the fk values that must be inserted onto the indirection table. There is a problem if you want to store more data other than the fk values, thats wy I´m planning to make MtoNImplementos configurable in your repository.xml file so that ojb uses your implementation to map M:N . Please see PersistenceBrokerImpl MtoN related methods. On Mon, 8 Dec 2003 10:59:08 +0100, "Reda Benzair" <[EMAIL PROTECTED]> escreveu: > De: "Reda Benzair" <[EMAIL PROTECTED]> > Data: Mon, 8 Dec 2003 10:59:08 +0100 > Para: "'OJB Users List'" <[EMAIL PROTECTED]> > Assunto: mapping M:N relation WITH ATTRIBUTES > > > Hi Rodrigo > Thank you very much for your response > I have another question? > I can have more information on your implementation for this problem of > MtoNImplementors ? > What is your solution > And can Help you for implemente this solution > Because this problem is very important for my application and my only > the solution for me at this time is convert the M:N to 1:N but is bad > solution ! > > > > -Original Message- > From: Leandro Rodrigo Saad Cruz [mailto:[EMAIL PROTECTED] > Sent: mercredi 3 décembre 2003 14:40 > To: OJB Users List > Subject: Re: mapping M:N relation WITH ATTRIBUTES > > Hi Reda. I´m working on this problem through the implementation of > specific MtoNImplementors. > I dunno when I´ll be able to finish this.. but this is supposed to solve > problems like yours. > > On Wed, 3 Dec 2003 13:22:54 +0100, "Reda Benzair" > <[EMAIL PROTECTED]> escreveu: > > > De: "Reda Benzair" <[EMAIL PROTECTED]> > > Data: Wed, 3 Dec 2003 13:22:54 +0100 > > Para: "'OJB Users List'" <[EMAIL PROTECTED]> > > Assunto: mapping M:N relation WITH ATTRIBUTES > > > > Hi all, > > > > I would like to map an M:N relation WITH ATTRIBUTES but seem to be > > unable to do it with OJB... > > By "WITH ATTRIBUTES" I mean that there is typically some more fields > in > > the indirection table than just foreign keys. > > Do I have to use 1:N N:1 mapping instead? > > > > A dummy example: > > > > Table Employee Table Employee_Company (M:N)Table > > Company > > -- --- > > -- > > EMP_ID CPY_ID CPY_ID > > NAME EMP_ID NAME > > Comment > > > > > > > > How can I map the "Comment" field if I use a M:N mapping? If it's not > > possible today, will it ever be? when? > > > > > > > > I'm currently using RC4 with Oracle 8i. > > > > > > > > I thank you in advance, > > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > -- > Leandro Rodrigo Saad Cruz > IT - Inter Business Tecnologia e > Serviços (IB) > http://www.ibnetwork.com.br > http://db.apache.org/ojb > http://xingu.sf.net > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > -- Leandro Rodrigo Saad Cruz IT - Inter Business Tecnologia e Serviços (IB) http://www.ibnetwork.com.br http://db.apache.org/ojb http://xingu.sf.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping M:N relation WITH ATTRIBUTES
Where would the Comment field be stored in the Java objects ? If you have a separate Java class for the connection between Employees and Companies which contains the Comment field, then you already have manual decomposition (see http://db.apache.org/ojb/tutorial3.html#Manual%20decomposition%20into%20two%201:n%20associations). Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping M:N relation WITH ATTRIBUTES
Hi Reda. I´m working on this problem through the implementation of specific MtoNImplementors. I dunno when I´ll be able to finish this.. but this is supposed to solve problems like yours. On Wed, 3 Dec 2003 13:22:54 +0100, "Reda Benzair" <[EMAIL PROTECTED]> escreveu: > De: "Reda Benzair" <[EMAIL PROTECTED]> > Data: Wed, 3 Dec 2003 13:22:54 +0100 > Para: "'OJB Users List'" <[EMAIL PROTECTED]> > Assunto: mapping M:N relation WITH ATTRIBUTES > > Hi all, > > I would like to map an M:N relation WITH ATTRIBUTES but seem to be > unable to do it with OJB... > By "WITH ATTRIBUTES" I mean that there is typically some more fields in > the indirection table than just foreign keys. > Do I have to use 1:N N:1 mapping instead? > > A dummy example: > > Table Employee Table Employee_Company (M:N)Table > Company > -- --- > -- > EMP_ID CPY_ID CPY_ID > NAME EMP_ID NAME > Comment > > > > How can I map the "Comment" field if I use a M:N mapping? If it's not > possible today, will it ever be? when? > > > > I'm currently using RC4 with Oracle 8i. > > > > I thank you in advance, > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- Leandro Rodrigo Saad Cruz IT - Inter Business Tecnologia e Serviços (IB) http://www.ibnetwork.com.br http://db.apache.org/ojb http://xingu.sf.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping question
Hello Eric, the descriptor as example: The join has to be made from ClassA:B to ClassB:Y, ie the where condition has to be where A0.B = A1.Y instead of A0.A = A1.Y What do I have to do to get this join? Thanks, Norbert. -Original Message- From: eric barbe [mailto:[EMAIL PROTECTED] Sent: Freitag, 28. November 2003 15:08 To: OJB Users List Subject: RE: Mapping question Hi, I don't really understand you're pb. ;o( Is it : any field from my class A can be THE foreign key (mykey in this case) from my class B ? Regards Éric -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoyé : jeudi 27 novembre 2003 17:49 À : [EMAIL PROTECTED] Objet : RE: Mapping question Thanks, I defined it like that, but: >If A is 1 and B is n. >In A class descriptor write : >element-class-ref="url.B"> > > >And in B class descriptor write this > >Here mykey is the foreignkey but not a primary key ! OJB generates statements where mykey points to the pk of class A. The generated join looks like: A.pk = B.mykey We need: A.anyField = B.mykey In fact I think we've a m:n mapping without intermediary table... What can we do (the database model cannot be changed)? Is there a possibility to add to the collection-descriptor something like similar to the element? Thanks again. -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoyé : jeudi 27 novembre 2003 16:57 À : [EMAIL PROTECTED] Objet : Mapping question Hi, I've got a 1:n mapping from table A to table B. But the foreign key field of table A is not it's primary key. I can't find how to tell OJB to use another field to join table B. Thanks for help, Norbert. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping question
Hi, I don't really understand you're pb. ;o( Is it : any field from my class A can be THE foreign key (mykey in this case) from my class B ? Regards Éric -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoyé : jeudi 27 novembre 2003 17:49 À : [EMAIL PROTECTED] Objet : RE: Mapping question Thanks, I defined it like that, but: >If A is 1 and B is n. >In A class descriptor write : >element-class-ref="url.B"> > > >And in B class descriptor write this > >Here mykey is the foreignkey but not a primary key ! OJB generates statements where mykey points to the pk of class A. The generated join looks like: A.pk = B.mykey We need: A.anyField = B.mykey In fact I think we've a m:n mapping without intermediary table... What can we do (the database model cannot be changed)? Is there a possibility to add to the collection-descriptor something like similar to the element? Thanks again. -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoyé : jeudi 27 novembre 2003 16:57 À : [EMAIL PROTECTED] Objet : Mapping question Hi, I've got a 1:n mapping from table A to table B. But the foreign key field of table A is not it's primary key. I can't find how to tell OJB to use another field to join table B. Thanks for help, Norbert. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping question
Thanks, I defined it like that, but: >If A is 1 and B is n. >In A class descriptor write : >element-class-ref="url.B"> > > >And in B class descriptor write this > >Here mykey is the foreignkey but not a primary key ! OJB generates statements where mykey points to the pk of class A. The generated join looks like: A.pk = B.mykey We need: A.anyField = B.mykey In fact I think we've a m:n mapping without intermediary table... What can we do (the database model cannot be changed)? Is there a possibility to add to the collection-descriptor something like similar to the element? Thanks again. -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoyé : jeudi 27 novembre 2003 16:57 À : [EMAIL PROTECTED] Objet : Mapping question Hi, I've got a 1:n mapping from table A to table B. But the foreign key field of table A is not it's primary key. I can't find how to tell OJB to use another field to join table B. Thanks for help, Norbert. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping question
Hi, If A is 1 and B is n. In A class descriptor write : And in B class descriptor write this Here mykey is the foreignkey but not a primary key ! Hope it helps you, Éric -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoyé : jeudi 27 novembre 2003 16:57 À : [EMAIL PROTECTED] Objet : Mapping question Hi, I've got a 1:n mapping from table A to table B. But the foreign key field of table A is not it's primary key. I can't find how to tell OJB to use another field to join table B. Thanks for help, Norbert. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping association in one table
Thank it works fine remi - Original Message - From: "Nick Ohanian" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Thursday, November 13, 2003 7:36 PM Subject: Re: Mapping association in one table > Hi- > > I'm a little new at OJB, but I think it's possible. Take a look at the > section on nested objects at > http://db.apache.org/ojb/tutorial3.html#nested%20objects, specifically > the class-descriptor listed in that section. > > Your repository.xml should something like > > > >name="firstB::string1" > column="firstB_string1" > /> >name="firstB::string2" > column="firstB_string2" > /> >name="secondB::string1" > column="secondB_string1" > /> >name="secondB::string2" > column="secondB_string2" > /> > > > Hope that helps. > > -Nick > > > > On Thu, 2003-11-13 at 08:54, RÃmi Bars wrote: > > Hi all, > > > > in my application i have an association between 2 objects A and B. i want to > > store the items of B in the A table , is it possible? how can i do that > > with the odmg api, how can i map that in the repository?is it a stupid > > question? > > > > Sample : > > class A { > > int id > > B firstB; > > B secondB > > } > > class B { > > string string1; > > string string2; > > } > > > > create table A(id int primary key not null, firstB_string1 varchar(20), > > firstB_string2 varchar(20),secondB_string1 varchar(20),secondB_string2 > > varchar(20)) > > > > thank > > > > Remi > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping association in one table
Hi- I'm a little new at OJB, but I think it's possible. Take a look at the section on nested objects at http://db.apache.org/ojb/tutorial3.html#nested%20objects, specifically the class-descriptor listed in that section. Your repository.xml should something like Hope that helps. -Nick On Thu, 2003-11-13 at 08:54, RÃmi Bars wrote: > Hi all, > > in my application i have an association between 2 objects A and B. i want to > store the items of B in the A table , is it possible? how can i do that > with the odmg api, how can i map that in the repository?is it a stupid > question? > > Sample : > class A { > int id > B firstB; > B secondB > } > class B { > string string1; > string string2; > } > > create table A(id int primary key not null, firstB_string1 varchar(20), > firstB_string2 varchar(20),secondB_string1 varchar(20),secondB_string2 > varchar(20)) > > thank > > Remi > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping many classes to one table
hi david, please add a feature-request to scarab. jakob David Corbin wrote: On Friday 31 October 2003 14:47, Jakob Braeuchi wrote: hi, Robert J Celestino wrote: David, I believe that you must write 30 class descriptors all exactly the same except for the class name :-( I have not been able to get this sort of scenario to work any other way. It seems odd, since ojb "should" know the inheritance structure due to the extent-class tag. It would be nice if extent classes need only add field-descriptors for the attributes that are different. the problem is that descriptors are not inherited by extent class. At the least, it would be nice if I could specify one class-descriptor as being inherited from another. Even that seems way less than ideal. jakob Bob c Bob Celestino SAS Research and Development 919 - 531 - 9425 [EMAIL PROTECTED] SAS - The Power to Know > -Original Message- > From: David Corbin [mailto:[EMAIL PROTECTED] > Sent: Friday, October 31, 2003 2:37 PM > To: OJB Users List; Jakob Braeuchi > Subject: Re: mapping many classes to one table > > On Friday 31 October 2003 14:11, Jakob Braeuchi wrote: > > hi david, > > > > > > why don't you use ojbConcreteClass ? > > I don't understand. I fully plan on having something like > this so I can > materialize the correct type object. That has little (as > far as I can tell) > to do with my problem. As far as I can tell, unless I write 30 > class-descriptors, those objects of that class are believe > to not be > persistable. > > > David Corbin wrote: > > > I have a class heirarchy, and there are 30 different concrete > > > classes in it. There is NO difference in the data, just > > in behavior. > > > > I'm well aware of how to read these in from a common > > table using a > > > > RowReader. > > > > > > Do I have to write 30 class-descriptors all of which > > look exactly > > > > the same except for the class name? > > > > yes, if you do not want to copy paste ;) > > > > jakob > > > > > Thanks > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > David Corbin <[EMAIL PROTECTED]> > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: mapping many classes to one table
You could consider changing your design to use delegation rather than inheritance. Let's say you have class A that contains all the data and subclasses A1 through A30 that contain the different behavior. You could move the data to class B and have class A hold on to an instance of class B. So in the code for A1 through A30, your code would change from this.getName() to this.getB().getName(). Or you could duplicate all the getters from B in A, so your subclasses wouldn't change at all. That way you'd only have 1 class descriptor. Just a thought :-) Greg -Original Message- From: Jakob Braeuchi [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 1:48 PM To: OJB Users List Subject: Re: mapping many classes to one table hi, Robert J Celestino wrote: > David, > > I believe that you must write 30 class descriptors all exactly the > same except for the class name :-( I have not been able to get this sort of scenario to work any other way. > > It seems odd, since ojb "should" know the inheritance structure due to > the extent-class tag. It would be nice if extent classes need only add field-descriptors for the attributes that are different. > the problem is that descriptors are not inherited by extent class. jakob > Bob c > > > Bob Celestino > SAS Research and Development > 919 - 531 - 9425 > [EMAIL PROTECTED] > > SAS - The Power to Know > > > > -Original Message- > > From: David Corbin [mailto:[EMAIL PROTECTED] > > Sent: Friday, October 31, 2003 2:37 PM > > To: OJB Users List; Jakob Braeuchi > > Subject: Re: mapping many classes to one table > > > > > > On Friday 31 October 2003 14:11, Jakob Braeuchi wrote: > > > hi david, > > > > > > > > why don't you use ojbConcreteClass ? > > > > I don't understand. I fully plan on having something like > > this so I can > > materialize the correct type object. That has little (as > > far as I can tell) > > to do with my problem. As far as I can tell, unless I write 30 > > class-descriptors, those objects of that class are believe > > to not be > > persistable. > > > > > > > > > > David Corbin wrote: > > > > I have a class heirarchy, and there are 30 different concrete > > > > classes in it. There is NO difference in the data, just > > in behavior. > > > > I'm well aware of how to read these in from a common > > table using a > > > > RowReader. > > > > > > > > Do I have to write 30 class-descriptors all of which > > look exactly > > > > the same except for the class name? > > > > > > yes, if you do not want to copy paste ;) > > > > > > jakob > > > > > > > Thanks > > > > > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > > David Corbin <[EMAIL PROTECTED]> > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping many classes to one table
On Friday 31 October 2003 14:47, Jakob Braeuchi wrote: > hi, > > Robert J Celestino wrote: > > David, > > > > I believe that you must write 30 class descriptors all exactly the same > > except for the class name :-( I have not been able to get this sort of > > scenario to work any other way. > > > > It seems odd, since ojb "should" know the inheritance structure due to > > the extent-class tag. It would be nice if extent classes need only add > > field-descriptors for the attributes that are different. > > the problem is that descriptors are not inherited by extent class. At the least, it would be nice if I could specify one class-descriptor as being inherited from another. Even that seems way less than ideal. > > jakob > > > Bob c > > > > > > Bob Celestino > > SAS Research and Development > > 919 - 531 - 9425 > > [EMAIL PROTECTED] > > > > SAS - The Power to Know > > > > > -Original Message- > > > From: David Corbin [mailto:[EMAIL PROTECTED] > > > Sent: Friday, October 31, 2003 2:37 PM > > > To: OJB Users List; Jakob Braeuchi > > > Subject: Re: mapping many classes to one table > > > > > > On Friday 31 October 2003 14:11, Jakob Braeuchi wrote: > > > > hi david, > > > > > > > > > > > > why don't you use ojbConcreteClass ? > > > > > > I don't understand. I fully plan on having something like > > > this so I can > > > materialize the correct type object. That has little (as > > > far as I can tell) > > > to do with my problem. As far as I can tell, unless I write 30 > > > class-descriptors, those objects of that class are believe > > > to not be > > > persistable. > > > > > > > David Corbin wrote: > > > > > I have a class heirarchy, and there are 30 different concrete > > > > > classes in it. There is NO difference in the data, just > > > > > > in behavior. > > > > > > > > I'm well aware of how to read these in from a common > > > > > > table using a > > > > > > > > RowReader. > > > > > > > > > > Do I have to write 30 class-descriptors all of which > > > > > > look exactly > > > > > > > > the same except for the class name? > > > > > > > > yes, if you do not want to copy paste ;) > > > > > > > > jakob > > > > > > > > > Thanks > > > > > > > > > - > > > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -- > > > David Corbin <[EMAIL PROTECTED]> > > > > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- David Corbin <[EMAIL PROTECTED]> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping many classes to one table
hi, Robert J Celestino wrote: David, I believe that you must write 30 class descriptors all exactly the same except for the class name :-( I have not been able to get this sort of scenario to work any other way. It seems odd, since ojb "should" know the inheritance structure due to the extent-class tag. It would be nice if extent classes need only add field-descriptors for the attributes that are different. the problem is that descriptors are not inherited by extent class. jakob Bob c Bob Celestino SAS Research and Development 919 - 531 - 9425 [EMAIL PROTECTED] SAS - The Power to Know > -Original Message- > From: David Corbin [mailto:[EMAIL PROTECTED] > Sent: Friday, October 31, 2003 2:37 PM > To: OJB Users List; Jakob Braeuchi > Subject: Re: mapping many classes to one table > > > On Friday 31 October 2003 14:11, Jakob Braeuchi wrote: > > hi david, > > > > > why don't you use ojbConcreteClass ? > > I don't understand. I fully plan on having something like > this so I can > materialize the correct type object. That has little (as > far as I can tell) > to do with my problem. As far as I can tell, unless I write 30 > class-descriptors, those objects of that class are believe > to not be > persistable. > > > > > > David Corbin wrote: > > > I have a class heirarchy, and there are 30 different concrete > > > classes in it. There is NO difference in the data, just > in behavior. > > > I'm well aware of how to read these in from a common > table using a > > > RowReader. > > > > > > Do I have to write 30 class-descriptors all of which > look exactly > > > the same except for the class name? > > > > yes, if you do not want to copy paste ;) > > > > jakob > > > > > Thanks > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > David Corbin <[EMAIL PROTECTED]> > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: mapping many classes to one table
David, I believe that you must write 30 class descriptors all exactly the same except for the class name :-( I have not been able to get this sort of scenario to work any other way. It seems odd, since ojb "should" know the inheritance structure due to the extent-class tag. It would be nice if extent classes need only add field-descriptors for the attributes that are different. Bob c Bob Celestino SAS Research and Development 919 - 531 - 9425 [EMAIL PROTECTED] SAS - The Power to Know > -Original Message- > From: David Corbin [mailto:[EMAIL PROTECTED] > Sent: Friday, October 31, 2003 2:37 PM > To: OJB Users List; Jakob Braeuchi > Subject: Re: mapping many classes to one table > > > On Friday 31 October 2003 14:11, Jakob Braeuchi wrote: > > hi david, > > > > > why don't you use ojbConcreteClass ? > > I don't understand. I fully plan on having something like > this so I can > materialize the correct type object. That has little (as > far as I can tell) > to do with my problem. As far as I can tell, unless I write 30 > class-descriptors, those objects of that class are believe > to not be > persistable. > > > > > > David Corbin wrote: > > > I have a class heirarchy, and there are 30 different concrete > > > classes in it. There is NO difference in the data, just > in behavior. > > > I'm well aware of how to read these in from a common > table using a > > > RowReader. > > > > > > Do I have to write 30 class-descriptors all of which > look exactly > > > the same except for the class name? > > > > yes, if you do not want to copy paste ;) > > > > jakob > > > > > Thanks > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > David Corbin <[EMAIL PROTECTED]> > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping many classes to one table
hi david, David Corbin wrote: On Friday 31 October 2003 14:11, Jakob Braeuchi wrote: hi david, why don't you use ojbConcreteClass ? I don't understand. I fully plan on having something like this so I can materialize the correct type object. That has little (as far as I can tell) well in this case writing a RowReader is not necessary. to do with my problem. As far as I can tell, unless I write 30 class-descriptors, those objects of that class are believe to not be persistable. yes that's true. David Corbin wrote: I have a class heirarchy, and there are 30 different concrete classes in it. There is NO difference in the data, just in behavior. I'm well aware of how to read these in from a common table using a RowReader. Do I have to write 30 class-descriptors all of which look exactly the same except for the class name? yes, if you do not want to copy paste ;) jakob Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping many classes to one table
On Friday 31 October 2003 14:11, Jakob Braeuchi wrote: > hi david, > > why don't you use ojbConcreteClass ? I don't understand. I fully plan on having something like this so I can materialize the correct type object. That has little (as far as I can tell) to do with my problem. As far as I can tell, unless I write 30 class-descriptors, those objects of that class are believe to not be persistable. > > David Corbin wrote: > > I have a class heirarchy, and there are 30 different concrete classes in > > it. There is NO difference in the data, just in behavior. I'm well aware > > of how to read these in from a common table using a RowReader. > > > > Do I have to write 30 class-descriptors all of which look exactly the > > same except for the class name? > > yes, if you do not want to copy paste ;) > > jakob > > > Thanks > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- David Corbin <[EMAIL PROTECTED]> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping many classes to one table
hi david, why don't you use ojbConcreteClass ? David Corbin wrote: I have a class heirarchy, and there are 30 different concrete classes in it. There is NO difference in the data, just in behavior. I'm well aware of how to read these in from a common table using a RowReader. Do I have to write 30 class-descriptors all of which look exactly the same except for the class name? yes, if you do not want to copy paste ;) jakob Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping byte or tinyint(1) to boolean
Hi, Yassine Lajmi wrote: Hi all, In my db table i have a tinyint(1) column. can i map it to a boolean or Boolean attribute in my java bean ? yes, see http://db.apache.org/ojb/jdbc-types.html field conversion. There are many FieldConversion implementations shipped with OJB. (e.g. Boolean2IntFieldConversion) regards, Armin thank's - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping problem or something VERY wierd...
The mapping needed the obvious primary key On Thu, 2003-10-23 at 17:15, Andy Czerwonka wrote: > In looking at the SQL, and update is done when I do the store.. hey I > think the PK is NOT unique... yup - it's not unique... that's gotta be > the problem... > > On Thu, 2003-10-23 at 16:07, Andy Czerwonka wrote: > > I've got a simple 1..n association and I'm doing something like > > this...(pardon the syntax... just trying to make a point) > > > > Parent parent = new Parent() > > Child c1 = new Child(parent); > > Child c2 = new Child(parent); > > parent.getChildren.add(c1); > > parent.getChildren.add(c2); > > broker.store(parent); > > broker.commit(); > > > > database looks good... 1 record in the parent table and 2 in the child > > table with fk point back to the parent record...looks like: > > > > parent > > +--c1 > > +--c2 > > > > > > and then all hell breaks loose... > > > > Parent found = broker.query(parent); > > > > so far, so good, looks like it came from the cache... all references > > look good, still have: > > > > parent > > +--c1 > > +--c2 > > > > checked the database.. all good.. > > > > parent.setAnotherAttribute("changed state of parent"); > > broker.store(parent); > > > > still all good.. checked the database... > > > > and NOW > > > > broker.commit(); > > > > look in the database, and I see: > > > > parent > > +--c2 > > +--c2 > > > > HHHEEELLLPPP > > No Idea. > > > > -andy > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping problem or something VERY wierd...
In looking at the SQL, and update is done when I do the store.. hey I think the PK is NOT unique... yup - it's not unique... that's gotta be the problem... On Thu, 2003-10-23 at 16:07, Andy Czerwonka wrote: > I've got a simple 1..n association and I'm doing something like > this...(pardon the syntax... just trying to make a point) > > Parent parent = new Parent() > Child c1 = new Child(parent); > Child c2 = new Child(parent); > parent.getChildren.add(c1); > parent.getChildren.add(c2); > broker.store(parent); > broker.commit(); > > database looks good... 1 record in the parent table and 2 in the child > table with fk point back to the parent record...looks like: > > parent > +--c1 > +--c2 > > > and then all hell breaks loose... > > Parent found = broker.query(parent); > > so far, so good, looks like it came from the cache... all references > look good, still have: > > parent > +--c1 > +--c2 > > checked the database.. all good.. > > parent.setAnotherAttribute("changed state of parent"); > broker.store(parent); > > still all good.. checked the database... > > and NOW > > broker.commit(); > > look in the database, and I see: > > parent > +--c2 > +--c2 > > HHHEEELLLPPP > No Idea. > > -andy > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: mapping
Hi, Problem is that an class name attribute is empty. It seems that your first extent-class has an incorrectly spelled class-ref attribute (you have calls-ref). Cheers, Charles. > -Original Message- > From: Reitsam Andreas [mailto:[EMAIL PROTECTED] > Sent: 23 October 2003 08:18 > To: Ojb-User (E-Mail) > Subject: mapping > > > Hello. > > I tried to map multiple inteface inheritance like this: > > >class="de.sigel.business.mvgl.bo.Preis"> >calss-ref="de.sigel.business.mvgl.bo.MitbewerbervergleichPreis"/> >class-ref="de.sigel.business.mvgl.bo.KundenListPreisImpl" /> > > > >class="de.sigel.business.mvgl.bo.MitbewerbervergleichPreis"> >class-ref="de.sigel.business.mvgl.bo.KonkurrenzKundenPreisImpl" /> >class-ref="de.sigel.business.mvgl.bo.KonkurrenzHaendlerPreisImpl" /> >class-ref="de.sigel.business.mvgl.bo.SigelHaendlerPreisImpl" /> >class-ref="de.sigel.business.mvgl.bo.SigelKundenPreisImpl" /> > > > >class="de.sigel.business.mvgl.bo.KonkurrenzKundenPreisImpl" > table="TEST_PREISE"> > > name="ojbConcreteClass" > column="CLASS_NAME" > jdbc-type="VARCHAR"/> > > > > What's wrong with this, because a NullPointerException is thrown. > > java.lang.NullPointerException > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Class.java:219) > at > org.apache.ojb.broker.util.ClassHelper.getClass(Unknown Source) > at > org.apache.ojb.broker.util.ClassHelper.getClass(Unknown Source) > at > org.apache.ojb.broker.metadata.ClassDescriptor.getExtentClasse > s(Unknown > Source) > at > org.apache.ojb.broker.query.QueryFactory.getExtentClasses(Unknown > Source) > at > org.apache.ojb.broker.query.QueryFactory.addCriteriaForOjbConc > reteClasses(Un > known Source) > at > org.apache.ojb.broker.query.QueryFactory.newQuery(Unknown Source) > at > org.apache.ojb.broker.query.QueryFactory.newQuery(Unknown Source) > > > > thx, > andreas > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > This email and any attachments are strictly confidential and are intended solely for the addressee. If you are not the intended recipient you must not disclose, forward, copy or take any action in reliance on this message or its attachments. If you have received this email in error please notify the sender as soon as possible and delete it from your computer systems. Any views or opinions presented are solely those of the author and do not necessarily reflect those of HPD Software Limited or its affiliates. At present the integrity of email across the internet cannot be guaranteed and messages sent via this medium are potentially at risk. All liability is excluded to the extent permitted by law for any claims arising as a re- sult of the use of this medium to transmit information by or to HPD Software Limited or its affiliates. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping inheritence
Hi Sebastien, Leandros patch is in RC4 already. cheers, Thomas Sebastien Cesbron wrote: Hi, I'am new to OJB and I am looking at the archive to have some info. I've seen that supporting inheritence of descriptors in mapping repository is on the way :am I wrong ? If this is true, what is the status of this functionality ? In the june posts leandro said that he did a patch. Do I have to find this patch or is it sufficient for me if I take the last nightly build ? Thanx in advance Seb - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: mapping 1:n association with anonymous - again
I have tried the latest CVS release and the error still exists with anonymous tags. What class handles the mapping of the 1:n association? Reggie -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Monday, July 07, 2003 7:23 PM To: OJB Users List Subject: Re: mapping 1:n association with anonymous - again Hi Reggie, I think someone has modified (fixed?) the anonymous field stuff. Please try latest CVS. If this doesn't work please post again or make an issue on http://scarab.werken.com/scarab/issues/ regards, Armin - Original Message - From: "Reggie Hayes" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, July 07, 2003 3:13 PM Subject: mapping 1:n association with anonymous - again > I sent a message out a couple of days ago describing an error when > mappig a 1:n association using the anonymous attribute. Any work > arounds? Will this error be fixed in future releases? I am currently > using 1.0rc3. > > Thanks > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mapping classes to multiple data sources
Hi, Yes the Default cache is container wide. You should use the CachePerBrokerImpl to use separate cache regions for each jcdAlias. Thomas > -Original Message- > From: Wayne Kidd [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 30, 2003 3:01 AM > To: [EMAIL PROTECTED] > Subject: Re: Mapping classes to multiple data sources > > > I am trying to use the multiple datasources in the way of the current > solution. That is, I have 2 jdbc connections, each of them > has a full > set of the same tables. Therefore, only the jcdalias and its > parameters > are different. It turns out that they are schemas in the > same instance > of Oracle. Therefore 1 of the logged on users has USER1.TABA and the > other has USER2.TABA. The Class Descriptors are precisely the same > (since we do not specify the Schema name in the Class Descriptor of > TABA. This actually works up to a point. I am able to get an object > from USER1.TABA with key X. I can also get an object from USER2.TABA > with key Y. However, if I try to get an object from > USER2.TABA with key > X, I am returned the object even if it does not exist in > USER2.TABA. I > suspect this is due to cacheing, but I have not yet been able > to prove > that. I would rather not have to deploy the thing as 2 separate web > apps (not even sure that would solve the problem - maybe the cache is > container-wide). Does my speculation make sense (and if it does not, > what might be the real problem). > > > Thanks in advance > > Wayne > > > > I think this description is not very accurate. A long time ago we > > allowed to have different JDBC connections defined per class. > > > > But we dropped this feature, because it involved complex problems. > > For example it required us to provide a proper 2 phase > commit across > > multiple databases. > > > > The current solution is much simpler. A PersistenceBroker instance > > works with a dedicated Jdbc connection identified by a > jcdAlias in the > > repository.xml. > > So it is possible to work with one Broker for database A and with a > > second broker against database B. > > > > So it's still possible to persist objects to different > databases. But > > the management (e.g. 2phase commit) must be implemented by > user code. > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mapping classes to multiple data sources
I am trying to use the multiple datasources in the way of the current solution. That is, I have 2 jdbc connections, each of them has a full set of the same tables. Therefore, only the jcdalias and its parameters are different. It turns out that they are schemas in the same instance of Oracle. Therefore 1 of the logged on users has USER1.TABA and the other has USER2.TABA. The Class Descriptors are precisely the same (since we do not specify the Schema name in the Class Descriptor of TABA. This actually works up to a point. I am able to get an object from USER1.TABA with key X. I can also get an object from USER2.TABA with key Y. However, if I try to get an object from USER2.TABA with key X, I am returned the object even if it does not exist in USER2.TABA. I suspect this is due to cacheing, but I have not yet been able to prove that. I would rather not have to deploy the thing as 2 separate web apps (not even sure that would solve the problem - maybe the cache is container-wide). Does my speculation make sense (and if it does not, what might be the real problem). Thanks in advance Wayne I think this description is not very accurate. A long time ago we allowed to have different JDBC connections defined per class. But we dropped this feature, because it involved complex problems. For example it required us to provide a proper 2 phase commit across multiple databases. The current solution is much simpler. A PersistenceBroker instance works with a dedicated Jdbc connection identified by a jcdAlias in the repository.xml. So it is possible to work with one Broker for database A and with a second broker against database B. So it's still possible to persist objects to different databases. But the management (e.g. 2phase commit) must be implemented by user code. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping inheritance hierarchies????
Hello Cesar, Such inheritance mappings isn't supported in the current OJB version. My old schema was this kind of way, and I had to spend much hours to update my database's structure and its content. You may keep your current structure, but you won't be able to use inheritence within OJB. What I've done is (following your example) is : TABLE_A (ID, VALUE_A) TABLE_B (ID, VALUE_A, VALUE_B) And it's working quite well... Thomas At 00:37 25/07/2003, you wrote: Hi Cesar, hmm, I rather think I don't understand your problem. Declare all persistent classes in separate class-descriptor. If you need A and B objects to persist, declare a class-descriptor for each class (with all persistent fields, e.g. B need three field-descriptor). If you want to ask OJB for all A objects inclusive all inherited objects use the 'extent-class' tag in A to declare the extended classes. More info http://db.apache.org/ojb/tutorial3.html#extents and polymorphism regards, Armin - Original Message - From: "Cesar" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Thursday, July 24, 2003 10:41 PM Subject: Re: mapping inheritance hierarchies Sorry B extends A [ ]´s - Original Message - From: Cesar To: OJB Users List Sent: Thursday, July 24, 2003 4:03 PM Subject: mapping inheritance hierarchies People I have two tables(A and B) in my Database where A extends A How I make to map these class in the XML file? I already tried the suggested solution of 1:1 in tutorial3.html but it did´nt work - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping inheritance hierarchies????
Hi Cesar, hmm, I rather think I don't understand your problem. Declare all persistent classes in separate class-descriptor. If you need A and B objects to persist, declare a class-descriptor for each class (with all persistent fields, e.g. B need three field-descriptor). If you want to ask OJB for all A objects inclusive all inherited objects use the 'extent-class' tag in A to declare the extended classes. More info http://db.apache.org/ojb/tutorial3.html#extents and polymorphism regards, Armin - Original Message - From: "Cesar" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Thursday, July 24, 2003 10:41 PM Subject: Re: mapping inheritance hierarchies Sorry B extends A [ ]´s - Original Message - From: Cesar To: OJB Users List Sent: Thursday, July 24, 2003 4:03 PM Subject: mapping inheritance hierarchies People I have two tables(A and B) in my Database where A extends A How I make to map these class in the XML file? I already tried the suggested solution of 1:1 in tutorial3.html but it did´nt work - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mapping inheritance hierarchies????
Sorry B extends A [ ]´s - Original Message - From: Cesar To: OJB Users List Sent: Thursday, July 24, 2003 4:03 PM Subject: mapping inheritance hierarchies People I have two tables(A and B) in my Database where A extends A How I make to map these class in the XML file? I already tried the suggested solution of 1:1 in tutorial3.html but it did´nt work
Re: [MAPPING] MS SQL Server and DATETIME conversion
I'm using a SimpleDateTimeFormat to format (cutting time part) and parse again into date. It's not elegant, but works. Edson Richter - Original Message - From: "Geigl Maximilian, R235" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Thursday, July 17, 2003 1:15 PM Subject: AW: [MAPPING] MS SQL Server and DATETIME conversion Hello Edson, i'm still struggling with my problem. Can you pleas tell me how you ensure not to deliver time part. Max > -Ursprüngliche Nachricht- > Von: Edson Carlos Ericksson Richter > [mailto:[EMAIL PROTECTED] > Gesendet: Dienstag, 15. Juli 2003 21:08 > An: OJB Users List > Betreff: Re: [MAPPING] MS SQL Server and DATETIME conversion > > > I'm not sure, but I think you need a conversion: > > name="edatum" > > conversion="org.apache.ojb.broker.accesslayer.conversions.Java > Date2SqlTimest > ampFieldConversion" > column="EDATUM" > jdbc-type="DATE" > /> > > I've used this with SapDB and MS SQL 2K in my apps and worked > fine. You > should remember that java.sql.Date have different treatment than > java.util.Date. > > Of course, you should guarantee that you are not capturing > the time part > when inserting data... I'm using a function to truncate the > time part in my > apps. > > Best regards, > > Edson Richter > > - Original Message - > From: "Geigl Maximilian, R235" <[EMAIL PROTECTED]> > To: "OJB Users List" <[EMAIL PROTECTED]> > Sent: Tuesday, July 15, 2003 3:54 PM > Subject: [MAPPING] MS SQL Server and DATETIME conversion > > > Hello, > > i use OJB 1.0 rc2, MS SQL Server 2000 on WIN2K with the MS > JDBC driver and > have a date field: > > name="edatum" > column="EDATUM" > jdbc-type="DATE" > /> > > with the corresponding data type DATETIME in the datebase, > which can stores > date and time information in one field. > When i issue an INSERT that only has date information (like > '2003-03-04') > and execute a subsequent SELECT with a WHERE clause like > field='2003-03-04' > i do not get any result (all through OJB naturally). > > As far as i found out for the leading INSERT the (not given) > time part is > generated as 12:00:00.000, the SELECT looks for a DATETIME > value with the > time part like 00:00:00.000. and does not find any rows. > > Can somebody explain to me, how the generation of time parts > is working or > if i can configure this. Is it happening inside OJB (i don't > think as is > examined the p6spy log), the sql server or inside the jdbc > driver (which i > suspect, because the same example in query analyzer works). > > What can i do to work around this problem? Thank you for any > suggestions. > > Regards > Max > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.501 / Virus Database: 299 - Release Date: 14/7/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]