You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Hans Novak <hn...@repcom.de> on 2006/01/18 13:41:16 UTC

howto query this

Hi,

i try many hours (without a result) to query this sql statement:

SELECT count(*) FROM CALLS c, PHONE_NUMBER p, RFTELCO r
  WHERE c.PHONE_NUMBER_ID = p.PHONE_NUMBER_ID AND 
p.RF_TELKO_ID=r.RF_TELKO_ID
    AND r.RF_TELKO_ID =65;


Java Classes are CALLS, PHONE_NUMBER an RFTELCO.

PLEASE PLEASE HELP ME !


Hans

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: howto query this

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi hans,

imo you should post the relevant parts of your repository.

jakob

Hans Novak schrieb:
> hi,
> 
> hmm.... im not shure, but this is not enough, because the the sql 
> statement will look like this:
> 
> SELECT 
> RF_TELKO_ID,PARTNER_ID_USER,FIRST_NAME,LAST_NAME,NAME_SUFFIX,STREET,ZIP,CITY 
> FROM RFTELCO WHERE RF_TELKO_ID = 65
> 
> and
> 
> SELECT A0.PHONE_NUMBER_ID,A0.RF_TELKO_ID,A0.NUMBER FROM PHONE_NUMBER A0 
> WHERE A0.RF_TELKO_ID = 65
> 
> and
> 
> SELECT count(*) FROM CALLS A0 WHERE RF_TELKO_ID = 65
> 
> In Calls i dont have an "RF_TELKO_ID" and i get an mysql error.
> Your try will translate my wish in 3 seperate SQL querys.
> 
> How can i use the ReportQueryByCriteria  with more then one class, or is 
> it a chance to give the broker a native SQL script, without a class ?
> 
> 
> Hans
> 
> 
> Jakob Braeuchi schrieb:
>> hi hans,
>>
>> if you have the relationships properly defined, you'll not have to 
>> care about the joins.
>>
>> Criteria crit = new Criteria();
>> crit.addEqual("telcoId", new Integer(65));
>> ReportQueryByCriteria q = QueryFactory.newReportQuery(Calls.class, crit);
>> q.setAttributes(new String[]{"count(*)"});
>>
>> Iterator iter = broker.getReportQueryIteratorByQuery(q);
>>
>> as an alternative (if you're only interested in the count) you can use:
>>
>>
>> int count = broker.getCount(q);
>>
>> Hans Novak schrieb:
>>> Hi,
>>>
>>> this is already done before (and working).
>>> I can read and write to the database (mysql) with ojb criterias and 
>>> querys.
>>> My problem is, how i write the criterias and querys that will be 
>>> translated to a sql command like described.
>>>
>>> Hans
>>>
>>> Jakob Braeuchi schrieb:
>>>> hi hans,
>>>>
>>>> first you need to define all your classes and their relationships in 
>>>> the repository.xml . and then you could execute a report query 
>>>> selecting count(*).
>>>>
>>>> hth
>>>> jakob
>>>>
>>>> Hans Novak schrieb:
>>>>> Hi,
>>>>>
>>>>> i try many hours (without a result) to query this sql statement:
>>>>>
>>>>> SELECT count(*) FROM CALLS c, PHONE_NUMBER p, RFTELCO r
>>>>>  WHERE c.PHONE_NUMBER_ID = p.PHONE_NUMBER_ID AND 
>>>>> p.RF_TELKO_ID=r.RF_TELKO_ID
>>>>>    AND r.RF_TELKO_ID =65;
> 
> 
> 
> ------------------------------------------------------------------------
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 267.14.20/233 - Release Date: 18.01.2006
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: howto query this

Posted by Hans Novak <hn...@repcom.de>.
Jakob Braeuchi schrieb:
> hi hans,
>
> the repository_internal contains only ojb internal classes.
> please post the repository that defines your classes.
oh.... im sorry.
I hope, this is the right one.
I have an ant script, what create this Files automaticly, so i dont look 
in it, because it is working :)

Hans

Re: howto query this

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi hans,

the repository_internal contains only ojb internal classes.
please post the repository that defines your classes.

jakob

Hans Novak schrieb:
> Hello Thomas (and Jakob)
> 
> Thomas Franke schrieb:
>> I'll take a closer look to your statements and tables and try it. Did you
>> publish all your terms so that I can find them into the previous mails?
>>   
> 
> I'm not shure.
> So her are my classes and the repository: I hope, thats what you need.
> 
> Hans
> 
> 
> 
> ------------------------------------------------------------------------
> 
> package de.repcom.rftelco.core;
> 
> import java.sql.Date;
> import java.sql.Time;
> 
> import de.repcom.rftelco.core.Interface.InterfaceCalls;
> import de.repcom.rftelco.core.Interface.InterfacePhoneNumber;
> 
> /**
>  * @ojb.class table = "CALLS"
>  * 
>  */
> public class Calls implements InterfaceCalls{
> 	
> 	
> 	/**
> 	 * @ojb.field column = "CALLS_ID" primarykey = "true" autoincrement = "ojb"
> 	 */
> 	private int callsId;
> 	
> 	/**
> 	 * @ojb.field column = "PHONE_NUMBER_ID"
> 	 */
> 	private int phoneNumberId;
> 	
> 	/**
> 	 * @ojb.field column = "CALL_DATE"
> 	 */
> 	private Date callDate;
> 
> 	/**
> 	 * @ojb.field column = "CALL_TIME"
> 	 */
> 	private Time callTime;
> 	
> 	/**
> 	 * @ojb.field column = "NUMBER_CALLED" length = "250"
> 	 */
> 	private String numberCalled;
> 	
> 	
> 	
> 	/**
>     * @ojb.reference class-ref="de.repcom.rftelco.core.PhoneNumber"
>     *                foreignkey="phoneNumberId"
>     */	
> 	private InterfacePhoneNumber phoneNumber;
> 	
> 	
> 	
> 	public int getPhoneNumberId() {
> 		return phoneNumberId;
> 	}
> 
> 	public void setPhoneNumberId(int phoneNumberId) {
> 		this.phoneNumberId = phoneNumberId;
> 	}
> 
> 	public String getNumberCalled() {
> 		return numberCalled;
> 	}
> 
> 	public void setNumberCalled(String numberCalled) {
> 		this.numberCalled = numberCalled;
> 	}
> 
> 	public Date getCallDate() {
> 		return callDate;
> 	}
> 
> 	public void setCallDate(Date callDate) {
> 		this.callDate = callDate;
> 	}
> 
> 	public int getCallsId() {
> 		return callsId;
> 	}
> 
> 	public void setCallsId(int callsId) {
> 		this.callsId = callsId;
> 	}
> 
> 	public Time getCallTime() {
> 		return callTime;
> 	}
> 
> 	public void setCallTime(Time callTime) {
> 		this.callTime = callTime;
> 	}
> 
> 	public InterfacePhoneNumber getPhoneNumber() {
> 		return phoneNumber;
> 	}
> 
> 	public void setPhoneNumber(InterfacePhoneNumber phoneNumber) {
> 		this.phoneNumber = phoneNumber;
> 	}
> 
> 	public Calls(){
> 	}
> 
> 	
> 	
> }
> 
> 
> ------------------------------------------------------------------------
> 
> package de.repcom.rftelco.core;
> 
> import de.repcom.rftelco.core.Interface.InterfacePhoneNumber;
> 
> /**
>  * @ojb.class table = "PHONE_NUMBER" 
>  */
> public class PhoneNumber implements InterfacePhoneNumber{
> 
> 	/**
> 	 * @ojb.field column = "PHONE_NUMBER_ID" primarykey = "true" autoincrement = "ojb"
> 	 */
> 	private int phoneNumberId;
> 	
> 	/**
> 	 * @ojb.field column = "RF_TELKO_ID"
> 	 */
> 	private int rftelcoId;
> 	
> 	/**
> 	 * @ojb.field column = "NUMBER" length = "250"
> 	 */
> 	private String number;	
> 
> 	
> 	/**
> 	* @ojb.reference class-ref="de.repcom.rftelco.core.Rftelco"
> 	*                foreignkey="rftelcoId"
> 	*/		
> 	private Rftelco rftelco;
> 	
> 
> 	public Rftelco getRftelco() {
> 		return rftelco;
> 	}
> 
> 	public void setRftelco(Rftelco rftelco) {
> 		this.rftelco = rftelco;
> 	}
> 
> 	public String getNumber() {
> 		return number;
> 	}
> 
> 	public void setNumber(String number) {
> 		this.number = number;
> 	}
> 
> 	public int getPhoneNumberId() {
> 		return phoneNumberId;
> 	}
> 
> 	public void setPhoneNumberId(int phoneNumberId) {
> 		this.phoneNumberId = phoneNumberId;
> 	}
> 
> 	public int getRftelcoId() {
> 		return rftelcoId;
> 	}
> 
> 	public void setRftelcoId(int rftelcoId) {
> 		this.rftelcoId = rftelcoId;
> 	}	
> 	
> 	public PhoneNumber(){
> 		
> 	}
> 	public PhoneNumber(String number){
> 		this.number = number;
> 	}
> 
> 	
> }
> 
> 
> ------------------------------------------------------------------------
> 
> package de.repcom.rftelco.core;
> 
> import java.util.Vector;
> 
> import de.repcom.rftelco.core.Interface.InterfaceRftelco;
> 
> 
> /**
>  * @ojb.class table = "RFTELCO" 
>  */
> public class Rftelco implements InterfaceRftelco{
> 	private static final long serialVersionUID = 1L;
> 	
> 	/**
> 	 * @ojb.field column = "RF_TELKO_ID" primarykey = "true" autoincrement = "ojb"
> 	 */
> 	private int rftelcoId;
> 	
> 	/**
> 	 * @ojb.field column = "PARTNER_ID_USER" length = "250"
> 	 */
> 	private String partnerIdUser;
> 
> 	/**
> 	 * @ojb.field column = "FIRST_NAME" length = "250"
> 	 */
> 	private String firstName;
> 	
> 	/**
> 	 * @ojb.field column = "LAST_NAME" length = "250"
> 	 */
> 	private String lastName;
> 	
> 	/**
> 	 * @ojb.field column = "NAME_SUFFIX" length = "250"
> 	 */
> 	private String nameSuffix;
> 	
> 	/**
> 	 * @ojb.field column = "STREET" length = "250"
> 	 */
> 	private String street;
> 	
> 	/**
> 	 * @ojb.field column = "ZIP" length = "250"
> 	 */
> 	private String zip;
> 	
> 	/**
> 	 * @ojb.field column = "CITY" length = "250"
> 	 */
> 	private String city;
> 
> 	/*
> 	/**
> 	 * @ojb.field column = "CALLS_ID"
> 	*/
> 	//private int callsId;
> 	
> 	
> 	/*
> 	/**
> 	* @ojb.reference class-ref="de.repcom.rftelco.core.Calls"
> 	*                foreignkey="callsId"
> 	*/
> 	//private InterfaceCalls interfaceCalls;
> 	
> 	
> 	/**
> 	 * @ojb.collection element-class-ref="de.repcom.rftelco.core.PhoneNumber"
> 	 *                 foreignkey="rftelcoId" auto-retrieve="true"
> 	 *                 auto-update="true" auto-delete="true"
> 	 */
> 	private Vector phoneNumberList;
> 
> 	
> 	
> 	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 getNameSuffix() {
> 		return nameSuffix;
> 	}
> 
> 
> 	public void setNameSuffix(String nameSuffix) {
> 		this.nameSuffix = nameSuffix;
> 	}
> 
> 
> 	public String getPartnerIdUser() {
> 		return partnerIdUser;
> 	}
> 
> 
> 	public void setPartnerIdUser(String partnerIdUser) {
> 		this.partnerIdUser = partnerIdUser;
> 	}
> 
> 
> 	public int getRftelcoId() {
> 		return rftelcoId;
> 	}
> 
> 
> 	public void setRftelcoId(int rftelcoId) {
> 		this.rftelcoId = rftelcoId;
> 	}
> 
> 
> 	public String getStreet() {
> 		return street;
> 	}
> 
> 
> 	public void setStreet(String street) {
> 		this.street = street;
> 	}
> 
> 
> 	public String getZip() {
> 		return zip;
> 	}
> 
> 
> 	public void setZip(String zip) {
> 		this.zip = zip;
> 	}
> 
> 	public Rftelco(){
> 	}
> 
> 
> 	public Vector getPhoneNumberList() {
> 		return phoneNumberList;
> 	}
> 
> 
> 	public void setPhoneNumberList(Vector phoneNumberList) {
> 		this.phoneNumberList = phoneNumberList;
> 	}
> 
> 
> 	public String getCity() {
> 		return city;
> 	}
> 
> 
> 	public void setCity(String city) {
> 		this.city = city;
> 	}
> 
> 	
> 	public Rftelco(
> 			int rftelcoId,
> 			String partnerIdUser,
> 			String firstName, 
> 			String lastName, 
> 			String nameSuffix, 
> 			String street, 
> 			String zip,
> 			String city) {
> 		this.city = city;
> 		this.firstName = firstName;
> 		this.lastName = lastName;
> 		this.nameSuffix = nameSuffix;
> 		this.partnerIdUser = partnerIdUser;
> 		this.rftelcoId = rftelcoId;
> 		this.street = street;
> 		this.zip = zip;
> 	}
> 
> 
> 	
> 	
> 	
> }
> 
> 
> ------------------------------------------------------------------------
> 
> <!-- OJB INTERNAL MAPPINGS START HERE, DO NOT EDIT -->
> <!--
> #/* Copyright 2002-2004 The Apache Software Foundation
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
>  * You may obtain a copy of the License at
>  *
>  *     http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
> -->
> <!-- The OJB HIGH/LOW SequenceManagerTable -->
>    <class-descriptor
>       class="org.apache.ojb.broker.util.sequence.HighLowSequence"
>       table="OJB_HL_SEQ"
>    >
> 
>        <object-cache class="org.apache.ojb.broker.cache.ObjectCacheEmptyImpl">
>        </object-cache>
> 
>        <field-descriptor
>          name="tableName"
>          column="TABLENAME"
>          jdbc-type="VARCHAR"
>          primarykey="true"
>       />
>       <field-descriptor
>          name="fieldName"
>          column="FIELDNAME"
>          jdbc-type="VARCHAR"
>          primarykey="true"
>       />
>       <field-descriptor
>          name="maxKey"
>          column="MAX_KEY"
>          jdbc-type="BIGINT"
>       />
>       <field-descriptor
>          name="grabSize"
>          column="GRAB_SIZE"
>          jdbc-type="INTEGER"
>       />
>       <field-descriptor
>          name="version"
>          column="VERSION"
>          jdbc-type="INTEGER"
>          locking="true"
>       />
>    </class-descriptor>
> 
> 
> <!-- THIS IS THE OJB NAMED ROOTS TABLE, DO NOT EDIT-->
>    <class-descriptor
>    	  class="org.apache.ojb.odmg.NamedRootsMap$NamedEntry"
>    	  table="OJB_NRM"
>    >
>       <field-descriptor
>          name="name"
>          column="NAME"
>          jdbc-type="VARCHAR"
>          primarykey="true"
>       />
>       <field-descriptor
>          name="oid"
>          column="OID_"
>          jdbc-type="LONGVARBINARY"
>       />
>    </class-descriptor>
> 
> <!-- THIS IS THE OJB DLIST IMPLEMENTATION, DO NOT EDIT-->
>    <class-descriptor
>    	  class="org.apache.ojb.odmg.collections.DListImpl"
>    	  table="OJB_DLIST"
>    >
>       <field-descriptor
>          name="id"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"
>       />
> 
>       <collection-descriptor
>          name="elements"
>          element-class-ref="org.apache.ojb.odmg.collections.DListEntry"
>           auto-retrieve = "true"
>           auto-update="none"
>           auto-delete="none"
>       >
>          <inverse-foreignkey field-ref="dlistId"/>
>       </collection-descriptor>
>    </class-descriptor>
> 
> <!-- THIS IS THE OJB DLIST ENTRY IMPLEMENTATION, DO NOT EDIT-->
>    <class-descriptor
>       class="org.apache.ojb.odmg.collections.DListEntry"
>       table="OJB_DLIST_ENTRIES"
>    >
>       <field-descriptor
>          name="id"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"
>       />
>       <field-descriptor
>          name="dlistId"
>          column="DLIST_ID"
>          jdbc-type="INTEGER"
>       />
>       <field-descriptor
>          name="position"
>          column="POSITION_"
>          jdbc-type="INTEGER"
>       />
>       <field-descriptor
>          name="oid"
>          column="OID_"
>          jdbc-type="LONGVARBINARY"
>          conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion"
>       />
>    </class-descriptor>
> 
>    <!-- THIS IS THE OJB DBAG IMPLEMENTATION, DO NOT EDIT-->
>    <class-descriptor
>    	  class="org.apache.ojb.odmg.collections.DBagImpl"
>    	  table="OJB_DLIST"
>    >
>       <field-descriptor
>          name="id"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"
>       />
>       <collection-descriptor
>          name="elements"
>          element-class-ref="org.apache.ojb.odmg.collections.DListEntry"
>           auto-retrieve = "true"
>           auto-update="none"
>           auto-delete="none"
>       >
>          <inverse-foreignkey field-ref="dlistId"/>
>       </collection-descriptor>
>    </class-descriptor>
> 
> <!-- THIS IS THE OJB DSET IMPLEMENTATION, DO NOT EDIT-->
>    <class-descriptor
>    	  class="org.apache.ojb.odmg.collections.DSetImpl"
>    	  table="OJB_DSET"
>    >
>       <field-descriptor
>          name="id"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"
>       />
>       <collection-descriptor
>          name="elements"
>          element-class-ref="org.apache.ojb.odmg.collections.DSetEntry"
>           auto-retrieve = "true"
>           auto-update="none"
>           auto-delete="none"
>       >
>          <inverse-foreignkey field-ref="dlistId"/>
>       </collection-descriptor>
>    </class-descriptor>
> 
> <!-- THIS IS THE OJB DSET ENTRY IMPLEMENTATION, DO NOT EDIT-->
>    <class-descriptor
>    	  class="org.apache.ojb.odmg.collections.DSetEntry"
>    	  table="OJB_DSET_ENTRIES"
>    >
>       <field-descriptor
>          name="id"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"
>       />
>       <field-descriptor
>          name="dlistId"
>          column="DLIST_ID"
>          jdbc-type="INTEGER"
>       />
>       <field-descriptor
>          name="position"
>          column="POSITION_"
>          jdbc-type="INTEGER"
>       />
>       <field-descriptor
>          name="oid"
>          column="OID_"
>          jdbc-type="LONGVARBINARY"
>          conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion"
>       />
>    </class-descriptor>
> 
> <!-- THIS IS THE OJB DMAP IMPLEMENTATION, DO NOT EDIT-->
>    <class-descriptor
>    	  class="org.apache.ojb.odmg.collections.DMapImpl"
>    	  table="OJB_DMAP"
>    >
>       <field-descriptor
>          name="id"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"
>       />
>       <collection-descriptor
>          name="entries"
>          element-class-ref="org.apache.ojb.odmg.collections.DMapEntry"
>          collection-class="org.apache.ojb.broker.util.collections.ManageableHashSet"
>           auto-retrieve = "true"
>           auto-update="none"
>           auto-delete="none"
>       >
>          <inverse-foreignkey field-ref="dmapId"/>
>       </collection-descriptor>
>    </class-descriptor>
> 
> <!-- THIS IS THE OJB DMAP ENTRY IMPLEMENTATION, DO NOT EDIT-->
>    <class-descriptor
>    	  class="org.apache.ojb.odmg.collections.DMapEntry"
>    	  table="OJB_DMAP_ENTRIES"
>    >
>       <field-descriptor
>          name="id"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"
>       />
>       <field-descriptor
>          name="dmapId"
>          column="DMAP_ID"
>          jdbc-type="INTEGER"
>       />
>       <field-descriptor
>          name="keyOid"
>          column="KEY_OID"
>          jdbc-type="LONGVARBINARY"
>          conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion"
>       />
>       <field-descriptor
>          name="valueOid"
>          column="VALUE_OID"
>          jdbc-type="LONGVARBINARY"
>          conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion"
>       />
>    </class-descriptor>
> 
> 
> 
>    <!-- END OF OJB INTERNAL MAPPINGS-->
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> ------------------------------------------------------------------------
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 267.14.20/233 - Release Date: 18.01.2006
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: howto query this

Posted by Hans Novak <hn...@repcom.de>.
Hello Thomas (and Jakob)

Thomas Franke schrieb:
> I'll take a closer look to your statements and tables and try it. Did you
> publish all your terms so that I can find them into the previous mails?
>   

I'm not shure.
So her are my classes and the repository: I hope, thats what you need.

Hans



Re: howto query this

Posted by Thomas Franke <fr...@softenergy.de>.
Hans Novak wrote:

> Can you give me a hint howto realize that ?
I'll take a closer look to your statements and tables and try it. Did you
publish all your terms so that I can find them into the previous mails?

Regards,

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: howto query this

Posted by Hans Novak <hn...@repcom.de>.
Thomas Franke schrieb:
> Hans Novak wrote:
>   
>> How can i use the ReportQueryByCriteria  with more then one class, or is
>> it a chance to give the broker a native SQL script, without a class ?
>>     
> Maybe in this case you need a special class with your preferred reference
> descriptors?
>
>   
Can you give me a hint howto realize that ?

Hans

Re: howto query this

Posted by Thomas Franke <fr...@softenergy.de>.
Hans Novak wrote:

> How can i use the ReportQueryByCriteria  with more then one class, or is
> it a chance to give the broker a native SQL script, without a class ?
Maybe in this case you need a special class with your preferred reference
descriptors?

Regards,

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: howto query this

Posted by Hans Novak <hn...@repcom.de>.
hi,

hmm.... im not shure, but this is not enough, because the the sql 
statement will look like this:

SELECT 
RF_TELKO_ID,PARTNER_ID_USER,FIRST_NAME,LAST_NAME,NAME_SUFFIX,STREET,ZIP,CITY 
FROM RFTELCO WHERE RF_TELKO_ID = 65

and

SELECT A0.PHONE_NUMBER_ID,A0.RF_TELKO_ID,A0.NUMBER FROM PHONE_NUMBER A0 
WHERE A0.RF_TELKO_ID = 65

and

SELECT count(*) FROM CALLS A0 WHERE RF_TELKO_ID = 65

In Calls i dont have an "RF_TELKO_ID" and i get an mysql error.
Your try will translate my wish in 3 seperate SQL querys.

How can i use the ReportQueryByCriteria  with more then one class, or is 
it a chance to give the broker a native SQL script, without a class ?


Hans


Jakob Braeuchi schrieb:
> hi hans,
>
> if you have the relationships properly defined, you'll not have to 
> care about the joins.
>
> Criteria crit = new Criteria();
> crit.addEqual("telcoId", new Integer(65));
> ReportQueryByCriteria q = QueryFactory.newReportQuery(Calls.class, crit);
> q.setAttributes(new String[]{"count(*)"});
>
> Iterator iter = broker.getReportQueryIteratorByQuery(q);
>
> as an alternative (if you're only interested in the count) you can use:
>
>
> int count = broker.getCount(q);
>
> Hans Novak schrieb:
>> Hi,
>>
>> this is already done before (and working).
>> I can read and write to the database (mysql) with ojb criterias and 
>> querys.
>> My problem is, how i write the criterias and querys that will be 
>> translated to a sql command like described.
>>
>> Hans
>>
>> Jakob Braeuchi schrieb:
>>> hi hans,
>>>
>>> first you need to define all your classes and their relationships in 
>>> the repository.xml . and then you could execute a report query 
>>> selecting count(*).
>>>
>>> hth
>>> jakob
>>>
>>> Hans Novak schrieb:
>>>> Hi,
>>>>
>>>> i try many hours (without a result) to query this sql statement:
>>>>
>>>> SELECT count(*) FROM CALLS c, PHONE_NUMBER p, RFTELCO r
>>>>  WHERE c.PHONE_NUMBER_ID = p.PHONE_NUMBER_ID AND 
>>>> p.RF_TELKO_ID=r.RF_TELKO_ID
>>>>    AND r.RF_TELKO_ID =65;


-- 



	
------------------------------------------------------------------------

	
Repcom Datentechnik GmbH <http://www.repcom.de/>
Hauptstr. 103
63110 Rodgau
Tel. 06106-638081 - Fax 06106-638083 	
Bankverbindung:
Deutsche Bank Dietzenbach,
Kto. 1516400 BLZ 50570024
Öffnungszeiten:
Mo.-Fr. 14.00-18.30 Uhr
Tel. Hotline Mo.-Fr. 10.00-18.30 Uhr 	
Messenger
Yahoo
ICQ
	: bforpc
: 174290900
	MSN
AIM
	: bforpc@msn.com
: bforpc
IP Telefon Skype :    bforpc

Unsere Web Adressen 	
www.repcom.de <http://www.repcom.de>  www.refas.de <http://www.refas.de> 
www.dataportal.de <http://www.dataportal.de>

Nützliche Links:
Unsere AGB's <http://www.repcom.de/conditions.php>
Infos zu Dateianhängen 
<http://www.fsf.org/philosophy/no-word-attachments.de.html>
	Anfahrtsbeschreibung <http://www.repcom.de/bilder/repcomanfahrt.jpg>
Repcom Online Hilfe <http://www.repcom-help.de>

Vertraulichkeitshinweis
Der Inhalt dieser E-Mail, einschliesslich etwaiger Anhäge, ist 
vertraulich und nur für den oben bezeichneten Adressaten bestimmt. Wenn 
Sie nicht dieser Adressat oder dessen Empfangsvertreter sein sollten, so 
beachten Sie bitte, dass jede Form der Kenntnisnahme, Veröffentlichung, 
Vervielfältigung, Weitergabe oder eines anderen Gebrauchs des Inhalts 
nicht gestattet ist und gesetzeswidrig sein kann. Bitte informieren Sie 
in diesem Fall unverzglich den Absender und vernichten Sie dieses E-Mail 
nebst Anhängen und aller Kopien.

	
------------------------------------------------------------------------



Re: howto query this

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi hans,

if you have the relationships properly defined, you'll not have to care 
about the joins.

Criteria crit = new Criteria();
crit.addEqual("telcoId", new Integer(65));
ReportQueryByCriteria q = QueryFactory.newReportQuery(Calls.class, crit);
q.setAttributes(new String[]{"count(*)"});

Iterator iter = broker.getReportQueryIteratorByQuery(q);

as an alternative (if you're only interested in the count) you can use:


int count = broker.getCount(q);

Hans Novak schrieb:
> Hi,
> 
> this is already done before (and working).
> I can read and write to the database (mysql) with ojb criterias and querys.
> My problem is, how i write the criterias and querys that will be 
> translated to a sql command like described.
> 
> Hans
> 
> Jakob Braeuchi schrieb:
>> hi hans,
>>
>> first you need to define all your classes and their relationships in 
>> the repository.xml . and then you could execute a report query 
>> selecting count(*).
>>
>> hth
>> jakob
>>
>> Hans Novak schrieb:
>>> Hi,
>>>
>>> i try many hours (without a result) to query this sql statement:
>>>
>>> SELECT count(*) FROM CALLS c, PHONE_NUMBER p, RFTELCO r
>>>  WHERE c.PHONE_NUMBER_ID = p.PHONE_NUMBER_ID AND 
>>> p.RF_TELKO_ID=r.RF_TELKO_ID
>>>    AND r.RF_TELKO_ID =65;
>>>
>>>
>>> Java Classes are CALLS, PHONE_NUMBER an RFTELCO.
>>>
>>> PLEASE PLEASE HELP ME !
>>>
> 
> 
> 
> ------------------------------------------------------------------------
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 267.14.20/233 - Release Date: 18.01.2006
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: howto query this

Posted by Hans Novak <hn...@repcom.de>.
Hi,

this is already done before (and working).
I can read and write to the database (mysql) with ojb criterias and querys.
My problem is, how i write the criterias and querys that will be 
translated to a sql command like described.

Hans

Jakob Braeuchi schrieb:
> hi hans,
>
> first you need to define all your classes and their relationships in 
> the repository.xml . and then you could execute a report query 
> selecting count(*).
>
> hth
> jakob
>
> Hans Novak schrieb:
>> Hi,
>>
>> i try many hours (without a result) to query this sql statement:
>>
>> SELECT count(*) FROM CALLS c, PHONE_NUMBER p, RFTELCO r
>>  WHERE c.PHONE_NUMBER_ID = p.PHONE_NUMBER_ID AND 
>> p.RF_TELKO_ID=r.RF_TELKO_ID
>>    AND r.RF_TELKO_ID =65;
>>
>>
>> Java Classes are CALLS, PHONE_NUMBER an RFTELCO.
>>
>> PLEASE PLEASE HELP ME !
>>


-- 



	
------------------------------------------------------------------------

	
Repcom Datentechnik GmbH <http://www.repcom.de/>
Hauptstr. 103
63110 Rodgau
Tel. 06106-638081 - Fax 06106-638083 	
Bankverbindung:
Deutsche Bank Dietzenbach,
Kto. 1516400 BLZ 50570024
Öffnungszeiten:
Mo.-Fr. 14.00-18.30 Uhr
Tel. Hotline Mo.-Fr. 10.00-18.30 Uhr 	
Messenger
Yahoo
ICQ
	: bforpc
: 174290900
	MSN
AIM
	: bforpc@msn.com
: bforpc
IP Telefon Skype :    bforpc

Unsere Web Adressen 	
www.repcom.de <http://www.repcom.de>  www.refas.de <http://www.refas.de> 
www.dataportal.de <http://www.dataportal.de>

Nützliche Links:
Unsere AGB's <http://www.repcom.de/conditions.php>
Infos zu Dateianhängen 
<http://www.fsf.org/philosophy/no-word-attachments.de.html>
	Anfahrtsbeschreibung <http://www.repcom.de/bilder/repcomanfahrt.jpg>
Repcom Online Hilfe <http://www.repcom-help.de>

Vertraulichkeitshinweis
Der Inhalt dieser E-Mail, einschliesslich etwaiger Anhäge, ist 
vertraulich und nur für den oben bezeichneten Adressaten bestimmt. Wenn 
Sie nicht dieser Adressat oder dessen Empfangsvertreter sein sollten, so 
beachten Sie bitte, dass jede Form der Kenntnisnahme, Veröffentlichung, 
Vervielfältigung, Weitergabe oder eines anderen Gebrauchs des Inhalts 
nicht gestattet ist und gesetzeswidrig sein kann. Bitte informieren Sie 
in diesem Fall unverzglich den Absender und vernichten Sie dieses E-Mail 
nebst Anhängen und aller Kopien.

	
------------------------------------------------------------------------



Re: howto query this

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi hans,

first you need to define all your classes and their relationships in the 
repository.xml . and then you could execute a report query selecting 
count(*).

hth
jakob

Hans Novak schrieb:
> Hi,
> 
> i try many hours (without a result) to query this sql statement:
> 
> SELECT count(*) FROM CALLS c, PHONE_NUMBER p, RFTELCO r
>  WHERE c.PHONE_NUMBER_ID = p.PHONE_NUMBER_ID AND 
> p.RF_TELKO_ID=r.RF_TELKO_ID
>    AND r.RF_TELKO_ID =65;
> 
> 
> Java Classes are CALLS, PHONE_NUMBER an RFTELCO.
> 
> PLEASE PLEASE HELP ME !
> 
> 
> Hans
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: howto query this

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi hans,

please try the following count-query:

Criteria crit = new Criteria();
crit.addEqualTo("phoneNumber.rftelco.rftelcoId", new Integer(65));
broker.getCount(query);

the generated sql for hsqldb looks like this:

SELECT count(*) FROM CALLS A0 INNER JOIN PHONE_NUMBER A1 ON 
A0.PHONE_NUMBER_ID=A1.PHONE_NUMBER_ID WHERE A1.RF_TELKO_ID = '65'

as an alternative you could use a report-query:

ReportQueryByCriteria reportQuery = 
QueryFactory.newReportQuery(Calls.class, crit);
reportQuery.setAttributes(new String[]{"count(*)"});
Iterator iter = broker.getReportQueryIteratorByQuery(reportQuery);

hth
jakob

Thomas Franke schrieb:
> Hans Novak wrote:
> 
>> yes, this was my first way too. But the "addSql" will insert this sql
>> script after "select ... from .. [here will be inserted]"
> I see.
> 
> Regards,
> 
> Thomas
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: howto query this

Posted by Thomas Franke <fr...@softenergy.de>.
Hans Novak wrote:

> yes, this was my first way too. But the "addSql" will insert this sql
> script after "select ... from .. [here will be inserted]"
I see.

Regards,

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: howto query this

Posted by Hans Novak <hn...@repcom.de>.
Hi,

yes, this was my first way too. But the "addSql" will insert this sql 
script after "select ... from .. [here will be inserted]"

Hans


Thomas Franke schrieb:
> Hi Hans,
>   
>> PLEASE PLEASE HELP ME !
>>     
> How about to use ReportQueryByCriteria and the Criteria#addSql method? I think
> it's the best way to perform this.
>
>   


-- 



	
------------------------------------------------------------------------

	
Repcom Datentechnik GmbH <http://www.repcom.de/>
Hauptstr. 103
63110 Rodgau
Tel. 06106-638081 - Fax 06106-638083 	
Bankverbindung:
Deutsche Bank Dietzenbach,
Kto. 1516400 BLZ 50570024
Öffnungszeiten:
Mo.-Fr. 14.00-18.30 Uhr
Tel. Hotline Mo.-Fr. 10.00-18.30 Uhr 	
Messenger
Yahoo
ICQ
	: bforpc
: 174290900
	MSN
AIM
	: bforpc@msn.com
: bforpc
IP Telefon Skype :    bforpc

Unsere Web Adressen 	
www.repcom.de <http://www.repcom.de>  www.refas.de <http://www.refas.de> 
www.dataportal.de <http://www.dataportal.de>

Nützliche Links:
Unsere AGB's <http://www.repcom.de/conditions.php>
Infos zu Dateianhängen 
<http://www.fsf.org/philosophy/no-word-attachments.de.html>
	Anfahrtsbeschreibung <http://www.repcom.de/bilder/repcomanfahrt.jpg>
Repcom Online Hilfe <http://www.repcom-help.de>

Vertraulichkeitshinweis
Der Inhalt dieser E-Mail, einschliesslich etwaiger Anhäge, ist 
vertraulich und nur für den oben bezeichneten Adressaten bestimmt. Wenn 
Sie nicht dieser Adressat oder dessen Empfangsvertreter sein sollten, so 
beachten Sie bitte, dass jede Form der Kenntnisnahme, Veröffentlichung, 
Vervielfältigung, Weitergabe oder eines anderen Gebrauchs des Inhalts 
nicht gestattet ist und gesetzeswidrig sein kann. Bitte informieren Sie 
in diesem Fall unverzglich den Absender und vernichten Sie dieses E-Mail 
nebst Anhängen und aller Kopien.

	
------------------------------------------------------------------------



Re: howto query this

Posted by Thomas Franke <fr...@softenergy.de>.
Hi Hans,

> PLEASE PLEASE HELP ME !
How about to use ReportQueryByCriteria and the Criteria#addSql method? I think
it's the best way to perform this.

Hope I could help!

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org