Problem joining two tables with same column name
Hello I have a problem with OJB (version 1.0.0) and alias definition in the SQL statement. I have two tables (T1 and T2) and some off the columns in these two tables have the same name. When I try to query the first table with an attribute from the second table I always get this error message from the DBMS java.sql.SQLException: ORA-00918: column ambiguously defined The problem is that OJB doesn't use alias for the first table in the where clause. Here is an example for the statement: SELECT A0.COLUMN1,A0.COLUMN2,A0.COLUMN3,A0.COLUMN4 FROM T1 A0,T2 A1 WHERE A0.ID=A1.T1ID AND (( (COLUMN1 = '034') AND COLUMN2 = '78777') AND (A1.DATE = '1900-12-12 12:00:00.0')) There are no alias definition for the columns COLUMN1 and COLUMN2 but these columns are defined in both tables. That's the reason why the ORA-00918 exception is thrown by the DBMS. So is there a way to force the OJB framework to use alias definitions in the where clause or does somebody have another solution to fix my problem? I would really appreciate it if somebody could help me. Cheers Christian Java code that makes the query: == try { Criteria c = new Criteria(); // to set the alias on the criteria objects doesn't help // c.setAlias(a1); c.addColumnEqualTo(COLUMN1,034); c.addColumnEqualTo(COLUMN2,78777); // Criteria c2 = new Criteria(); // c2.setAlias(a2); // c2.addGreaterOrEqualThan(list.read,'1900-12-12 12:00:00.0'); c.addGreaterOrEqualThan(list.read,'1900-12-12 12:00:00.0'); // c.addAndCriteria(c2); QueryByCriteria query = new QueryByCriteria(A.class, c); Collection result = broker.getCollectionByQuery(query); return result; }catch (Exception e) { throw new MyException(text,e); }finally{ this.closeBroker(); } === Mapping definition from the repository.xml: === !-- Definition for table T1 -- class-descriptor class=A table=T1 field-descriptor name=t1id column=ID jdbc-type=INTEGER primarykey=true autoincrement=true / field-descriptor name=field1 column=COLUMN1 jdbc-type=VARCHAR / field-descriptor name=field2 column=COLUMN2 jdbc-type=VARCHAR / field-descriptor name=field3 column=COLUMN3 jdbc-type=VARCHAR / field-descriptor name=field4 column=COLUMN4 jdbc-type=VARCHAR / collection-descriptor name=list element-class-ref=B auto-retrieve=true auto-update=none inverse-foreignkey field-ref=t1id/ /collection-descriptor /class-descriptor !-- Definition for table T2 -- class-descriptor class=B table=T2 field-descriptor name=t2id column=ID jdbc-type=INTEGER primarykey=true autoincrement=true / field-descriptor name=t1id column=T1ID jdbc-type=INTEGER / field-descriptor name=field1 column=COLUMN1 jdbc-type=VARCHAR / field-descriptor name=field2 column=COLUMN2 jdbc-type=VARCHAR / field-descriptor name=read column=DATE jdbc-type=TIMESTAMP / reference-descriptor name=t1 class-ref=A auto-retrieve=true auto-update=none foreignkey field-ref=t1id / /reference-descriptor /class-descriptor ===
OJB and the X-Files... :)
Dear All, I have a simple inheritance relationship between a Special and ActivitySpecial. I'm using proxies throughout my project with the cglib proxy factory and indirection handler (I'm also using the broker API). I'm performing a simple query to find an activity special as follows: Special special = (Special) broker.getObjectByIdentity(new Identity(new Special(24), broker)); log.debug(Special: + special); Now here is the catch. When I set org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.LogLevel=DEBUG in the OJB-logging.properties file everything works fine. The correct object is materialized and when the debug statement is printed out the correct class ActivitySpecial is present. However when I set org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.LogLevel=WARN the object that is materialized is Special. This is really weird behavior. Does anyone have an idea why this would occur? I've included the mappings for the classes mentioned above as well as the entries I have for my database repository. Mappings: class-descriptor class=com.dm.beans.Special table=special field-descriptor name=id column=ID jdbc-type=INTEGER primarykey=true nullable=false autoincrement=true/ field-descriptor name=supplierId column=SUPPLIER_ID jdbc-type=INTEGER / field-descriptor name=name column=NAME jdbc-type=VARCHAR / field-descriptor name=ackOptLock column=ACK_OPT_LOCK jdbc-type=BIGINT locking=true/ reference-descriptor name=supplier class-ref=com.dm.beans.suppliers.Supplier proxy=true auto-update=link auto-delete=none foreignkey field-ref=supplierId/ /reference-descriptor collection-descriptor name=products collection-class=org.apache.ojb.broker.util.collections.RemovalAwareList element-class-ref=com.dm.beans.Product auto-update=link auto-delete=link proxy=true indirection-table=product_special fk-pointing-to-this-class column=SPECIAL_ID/ fk-pointing-to-element-class column=PRODUCT_ID/ /collection-descriptor /class-descriptor class-descriptor class=com.dm.beans.activity.ActivitySpecial table=activity_special field-descriptor name=id column=ID jdbc-type=INTEGER primarykey=true nullable=false/ field-descriptor name=minPersons column=MIN_PERSONS jdbc-type=INTEGER / field-descriptor name=maxPersons column=MAX_PERSONS jdbc-type=INTEGER / field-descriptor name=discount column=DISCOUNT jdbc-type=VARCHAR / reference-descriptor name=super class-ref=com.dm.beans.Special foreignkey field-ref=id/ /reference-descriptor /class-descriptor Database Repository Settings: jdbc-connection-descriptor jcd-alias=dataSource default-connection=true platform=MySQL jdbc-level=3.0 useAutoCommit=1 eager-release=false batch-mode=false jndi-datasource-name=java:comp/env/jdbc/DestinationDB ignoreAutoCommitExceptions=false !-- alternative cache implementations, see docs section Caching -- object-cache class=org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl !-- meaning of attributes, please see docs section Caching -- !-- common attributes -- attribute attribute-name=cacheExcludes attribute-value=/ !-- ObjectCacheTwoLevelImpl attributes -- attribute attribute-name=applicationCache attribute-value=org.apache.ojb.broker.cache.ObjectCacheOSCacheImpl/ attribute attribute-name=copyStrategy attribute-value=org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl$CopyStr ategyImpl/ attribute attribute-name=forceProxies attribute-value=false/ !-- ObjectCacheDefaultImpl attributes -- attribute attribute-name=timeout attribute-value=900/ attribute attribute-name=autoSync attribute-value=true/ attribute attribute-name=cachingKeyType attribute-value=0/ attribute attribute-name=useSoftReferences attribute-value=true/ /object-cache !-- For more info, see section Connection Handling in docs -- connection-pool maxActive=30 validationQuery=select 1 from supplier_type; testOnBorrow=true testOnReturn=false whenExhaustedAction=0 maxWait=1 !-- Set fetchSize to 0 to use driver's default. -- attribute attribute-name=fetchSize attribute-value=0/ !-- Attributes with name prefix jdbc. are passed directly to the JDBC driver. -- !-- Example setting (used by Oracle driver when Statement batching is enabled) -- attribute attribute-name=jdbc.defaultBatchValue attribute-value=5/ !-- Attributes determining if
Anyone using Generics?
Hello! I lately switched to Java 1.5 and get a lot of warnings like this: Type safety: The method add(Object) belongs to the raw type List. References to generic type ListE should be parameterized I know I can turn off those warnings. But is there a way to use Generics with OJB (for example for 1:n relations)? Thanks, Werner
Re: Anyone using Generics?
I'm just migrating a quite large app (about 300Kloc) to 1.5 and focus is using generics. In our case, app was split in several (6) layers, one is specialized in persistence. So, we make persistence layer return generyfied collections and add @SuppressWarnings(value={unchecked}) on these classes. At the rest of application, is mandatory developers could not use @SuppressWarnings - except in real generic code (like window managers capable of deal with Window, JFrame and JInternalFrame transparently). For the rest, generics rocks. But, if you use OJB code directly inside your GUI, then you'll have to add @SuppressWarnings - I made this question some time ago on this list, and there is no support for generics inside OJB. Best regards, Richter werner escreveu: Hello! I lately switched to Java 1.5 and get a lot of warnings like this: Type safety: The method add(Object) belongs to the raw type List. References to generic type ListE should be parameterized I know I can turn off those warnings. But is there a way to use Generics with OJB (for example for 1:n relations)? Thanks, Werner - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Anyone using Generics?
Well, I'm working on a web application. So I don't care too much about the warnings. Your solution seems very good to me. Thanks for your help. Werner Am Donnerstag, den 23.02.2006, 12:54 -0300 schrieb Edson Carlos Ericksson Richter: I'm just migrating a quite large app (about 300Kloc) to 1.5 and focus is using generics. In our case, app was split in several (6) layers, one is specialized in persistence. So, we make persistence layer return generyfied collections and add @SuppressWarnings(value={unchecked}) on these classes. At the rest of application, is mandatory developers could not use @SuppressWarnings - except in real generic code (like window managers capable of deal with Window, JFrame and JInternalFrame transparently). For the rest, generics rocks. But, if you use OJB code directly inside your GUI, then you'll have to add @SuppressWarnings - I made this question some time ago on this list, and there is no support for generics inside OJB. Best regards, Richter werner escreveu: Hello! I lately switched to Java 1.5 and get a lot of warnings like this: Type safety: The method add(Object) belongs to the raw type List. References to generic type ListE should be parameterized I know I can turn off those warnings. But is there a way to use Generics with OJB (for example for 1:n relations)? Thanks, Werner - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Fischer Masik OEG GEFi Informationstechnik und Datenservice Reisenbauerring 5/1/12 A-2351 Wiener Neudorf Tel: 02236 / 304 224 Fax: 02236 / 304 278 Mobil: 0676 528 97 57 Internet: http://www.gefi.at e-mail: persönlich: [EMAIL PROTECTED] allgemein: [EMAIL PROTECTED] * Confidentiality Notice * The information contained in this Email, and any attachments, is intended for the named recipients only. It may contain confidential and/or privileged information. If you are not the intended recipient, you must not copy, distribute, or take any action in reliance on it. Any views expressed do not necessarily reflect the views of the company. If you receive this Email by mistake, please advise the sender by using the reply facility in your Email software and then delete it.
CONNECTION POOL
Hi all, So in web application context (Tomcat), i want to configure OJB to make 10 pool connection to the database at the startup of the application. Normaly, whene we try to get new broker PersistenceBrokerFactory.defaultPersistenceBroker(); OJB retreive an existing and valide connection from the pool if not exist it create a new connection and put it in the pool. So my question is how to make for example 10 connection in the pool at the startup of my application. If you have some best practice of the connection pool in the context web i will be greatfull. OJB 1.0.3 I m using PB not ODMG. Default pool connection implementation. Thx in advance.