Query entity

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Query entity

Nattanicha Rittammanart
Hi all,
  I have a problem to ask you.
  I have table like this:

<entity package-name="org.ofbiz.ams.ams" entity-name="DepreciationTrans"
title="Keeps depreication record from depreciation table which created
in each period">
        <field type="id-ne" name="asset_itemid"></field>
        <field type="id-ne" name="depid"/>
        <field type="id" name="account_no"/>
        <field type="currency-amount" name="value_before_cal"/>
</entity>

I want to show it by using form, I do like this:

<form name="ShowDepreTables" type="list" list-name="depre_to_dates"
paginate-target="ShowDepreTable">
        <actions>
            <entity-condition entity-name="DepreciationTrans"><order-by
field-name="calculate_date"/></entity-condition>
        </actions>
        <field name="asset_itemid" title="asset itemid"><display/></field>
        <field name="depid" title="department id"><display/></field>
        <field name="account_no" title="account number"><display/></field>
        <field name="value_before_cal" title="before
price"><display/></field>
</form>

But asset_itemid is a field which link from another table. If I show
table as above, it will show asset_itemid. What I want is, I need it to
show asset_item_name. So, I do like this:

......
        <field name="asset_itemid" title="asset item name">
            <display-entity entity-name="AssetItems"
description="${asset_item_desc}"
key-field-name="asset_itemid"></display-entity>
        </field>
......

But it caused error like this

org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
[component://ams/widget/common/CommonScreens.xml#GlobalDecorator]:
java.lang.IllegalArgumentException: Error getting value from the
database for display of field [asset_itemid] on form [ShowDepreTables]:
org.ofbiz.entity.GenericModelException: [GenericDelegator.findOne]
Passed primary key is not a valid primary key:
[GenericEntity:AssetItems][asset_itemid,08000200010002(java.lang.String)]
(Error getting value from the database for display of field
[asset_itemid] on form [ShowDepreTables]:
org.ofbiz.entity.GenericModelException: [GenericDelegator.findOne]
Passed primary key is not a valid primary key:
[GenericEntity:AssetItems][asset_itemid,08000200010002(java.lang.String)])

How can I do to link asset_item_name from another table to show in table
which has asset_itemid??

Thank in advances,
Nattanicha
Reply | Threaded
Open this post in threaded view
|

Query entity

Nattanicha Rittammanart

> Hi all,
>  I have a problem to ask you.
>  I have table like this:
>
> <entity package-name="org.ofbiz.ams.ams"
> entity-name="DepreciationTrans" title="Keeps depreication record from
> depreciation table which created in each period">
>        <field type="id-ne" name="asset_itemid"></field>
>        <field type="id-ne" name="depid"/>
>        <field type="id" name="account_no"/>
>        <field type="currency-amount" name="value_before_cal"/>
> </entity>
>
> I want to show it by using form, I do like this:
>
> <form name="ShowDepreTables" type="list" list-name="depre_to_dates"
> paginate-target="ShowDepreTable">
>        <actions>
>            <entity-condition entity-name="DepreciationTrans"><order-by
> field-name="calculate_date"/></entity-condition>
>        </actions>
>        <field name="asset_itemid" title="asset itemid"><display/></field>
>        <field name="depid" title="department id"><display/></field>
>        <field name="account_no" title="account number"><display/></field>
>        <field name="value_before_cal" title="before
> price"><display/></field>
> </form>
>
> But asset_itemid is a field which link from another table. If I show
> table as above, it will show asset_itemid. What I want is, I need it
> to show asset_item_name. So, I do like this:
>
> ......
>        <field name="asset_itemid" title="asset item name">
>            <display-entity entity-name="AssetItems"
> description="${asset_item_desc}"
> key-field-name="asset_itemid"></display-entity>
>        </field>
> ......
>
> But it caused error like this
>
> org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
> [component://ams/widget/common/CommonScreens.xml#GlobalDecorator]:
> java.lang.IllegalArgumentException: Error getting value from the
> database for display of field [asset_itemid] on form
> [ShowDepreTables]: org.ofbiz.entity.GenericModelException:
> [GenericDelegator.findOne] Passed primary key is not a valid primary
> key:
> [GenericEntity:AssetItems][asset_itemid,08000200010002(java.lang.String)]
> (Error getting value from the database for display of field
> [asset_itemid] on form [ShowDepreTables]:
> org.ofbiz.entity.GenericModelException: [GenericDelegator.findOne]
> Passed primary key is not a valid primary key:
> [GenericEntity:AssetItems][asset_itemid,08000200010002(java.lang.String)])
>
>
> How can I do to link asset_item_name from another table to show in
> table which has asset_itemid??
>
> Thank in advances,
> Nattanicha
>

Reply | Threaded
Open this post in threaded view
|

RE: Query entity

SkipDever
One thing that jumps out at me is that I see no primary key.

Perhaps adding

      <prim-key field="asset_itemid"/>

and maybe if asset_itemid is not always unique

      <prim-key field="depid"/>

-----Original Message-----
From: Nattanicha Rittammanart [mailto:[hidden email]]
Sent: Sunday, April 20, 2008 1:38 PM
To: [hidden email]
Subject: Query entity



> Hi all,
>  I have a problem to ask you.
>  I have table like this:
>
> <entity package-name="org.ofbiz.ams.ams"
> entity-name="DepreciationTrans" title="Keeps depreication record from
> depreciation table which created in each period">
>        <field type="id-ne" name="asset_itemid"></field>
>        <field type="id-ne" name="depid"/>
>        <field type="id" name="account_no"/>
>        <field type="currency-amount" name="value_before_cal"/>
> </entity>
>
> I want to show it by using form, I do like this:
>
> <form name="ShowDepreTables" type="list" list-name="depre_to_dates"
> paginate-target="ShowDepreTable">
>        <actions>
>            <entity-condition entity-name="DepreciationTrans"><order-by
> field-name="calculate_date"/></entity-condition>
>        </actions>
>        <field name="asset_itemid" title="asset itemid"><display/></field>
>        <field name="depid" title="department id"><display/></field>
>        <field name="account_no" title="account number"><display/></field>
>        <field name="value_before_cal" title="before
> price"><display/></field>
> </form>
>
> But asset_itemid is a field which link from another table. If I show
> table as above, it will show asset_itemid. What I want is, I need it
> to show asset_item_name. So, I do like this:
>
> ......
>        <field name="asset_itemid" title="asset item name">
>            <display-entity entity-name="AssetItems"
> description="${asset_item_desc}"
> key-field-name="asset_itemid"></display-entity>
>        </field>
> ......
>
> But it caused error like this
>
> org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
> [component://ams/widget/common/CommonScreens.xml#GlobalDecorator]:
> java.lang.IllegalArgumentException: Error getting value from the
> database for display of field [asset_itemid] on form
> [ShowDepreTables]: org.ofbiz.entity.GenericModelException:
> [GenericDelegator.findOne] Passed primary key is not a valid primary
> key:
> [GenericEntity:AssetItems][asset_itemid,08000200010002(java.lang.String)]
> (Error getting value from the database for display of field
> [asset_itemid] on form [ShowDepreTables]:
> org.ofbiz.entity.GenericModelException: [GenericDelegator.findOne]
> Passed primary key is not a valid primary key:
> [GenericEntity:AssetItems][asset_itemid,08000200010002(java.lang.String)])
>
>
> How can I do to link asset_item_name from another table to show in
> table which has asset_itemid??
>
> Thank in advances,
> Nattanicha
>


No virus found in this incoming message.
Checked by AVG.
Version: 7.5.524 / Virus Database: 269.23.0/1381 - Release Date: 4/16/2008
9:34 AM

No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.524 / Virus Database: 269.23.0/1381 - Release Date: 4/16/2008
9:34 AM

Reply | Threaded
Open this post in threaded view
|

Re: Query entity

Mridul Pathak-2
You have not defined the prim-key fields and also you have not defined the
foreign key relationships if any of the field is coming from some other
entity.

On Mon, Apr 21, 2008 at 10:45 AM, skip@thedevers <[hidden email]> wrote:

> One thing that jumps out at me is that I see no primary key.
>
> Perhaps adding
>
>      <prim-key field="asset_itemid"/>
>
> and maybe if asset_itemid is not always unique
>
>      <prim-key field="depid"/>
>
> -----Original Message-----
> From: Nattanicha Rittammanart [mailto:[hidden email]]
> Sent: Sunday, April 20, 2008 1:38 PM
> To: [hidden email]
> Subject: Query entity
>
>
>
> > Hi all,
> >  I have a problem to ask you.
> >  I have table like this:
> >
> > <entity package-name="org.ofbiz.ams.ams"
> > entity-name="DepreciationTrans" title="Keeps depreication record from
> > depreciation table which created in each period">
> >        <field type="id-ne" name="asset_itemid"></field>
> >        <field type="id-ne" name="depid"/>
> >        <field type="id" name="account_no"/>
> >        <field type="currency-amount" name="value_before_cal"/>
> > </entity>
> >
> > I want to show it by using form, I do like this:
> >
> > <form name="ShowDepreTables" type="list" list-name="depre_to_dates"
> > paginate-target="ShowDepreTable">
> >        <actions>
> >            <entity-condition entity-name="DepreciationTrans"><order-by
> > field-name="calculate_date"/></entity-condition>
> >        </actions>
> >        <field name="asset_itemid" title="asset
> itemid"><display/></field>
> >        <field name="depid" title="department id"><display/></field>
> >        <field name="account_no" title="account
> number"><display/></field>
> >        <field name="value_before_cal" title="before
> > price"><display/></field>
> > </form>
> >
> > But asset_itemid is a field which link from another table. If I show
> > table as above, it will show asset_itemid. What I want is, I need it
> > to show asset_item_name. So, I do like this:
> >
> > ......
> >        <field name="asset_itemid" title="asset item name">
> >            <display-entity entity-name="AssetItems"
> > description="${asset_item_desc}"
> > key-field-name="asset_itemid"></display-entity>
> >        </field>
> > ......
> >
> > But it caused error like this
> >
> > org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
> > [component://ams/widget/common/CommonScreens.xml#GlobalDecorator]:
> > java.lang.IllegalArgumentException: Error getting value from the
> > database for display of field [asset_itemid] on form
> > [ShowDepreTables]: org.ofbiz.entity.GenericModelException:
> > [GenericDelegator.findOne] Passed primary key is not a valid primary
> > key:
> >
> [GenericEntity:AssetItems][asset_itemid,08000200010002(java.lang.String)]
> > (Error getting value from the database for display of field
> > [asset_itemid] on form [ShowDepreTables]:
> > org.ofbiz.entity.GenericModelException: [GenericDelegator.findOne]
> > Passed primary key is not a valid primary key:
> >
> [GenericEntity:AssetItems][asset_itemid,08000200010002(java.lang.String)])
> >
> >
> > How can I do to link asset_item_name from another table to show in
> > table which has asset_itemid??
> >
> > Thank in advances,
> > Nattanicha
> >
>
>
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.524 / Virus Database: 269.23.0/1381 - Release Date: 4/16/2008
> 9:34 AM
>
> No virus found in this outgoing message.
> Checked by AVG.
> Version: 7.5.524 / Virus Database: 269.23.0/1381 - Release Date: 4/16/2008
> 9:34 AM
>
>


--
Thanks & Regards
Mridul Pathak
Hotwax Media
http://www.hotwaxmedia.com
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Query entity

Nattanicha Rittammanart
Skip and Mridul
   Thanks very much for your help. My mistake is I have field name="id"
as my primary key. But field which I need to query is not a primary key.
So If I need to query field from another table, I need to query by
primary key only. I set the field which I need to query as primary key.
Then I can solve this problem.

Nattanicha

Mridul Pathak wrote:

> You have not defined the prim-key fields and also you have not defined the
> foreign key relationships if any of the field is coming from some other
> entity.
>
> On Mon, Apr 21, 2008 at 10:45 AM, skip@thedevers <[hidden email]> wrote:
>
>  
>> One thing that jumps out at me is that I see no primary key.
>>
>> Perhaps adding
>>
>>      <prim-key field="asset_itemid"/>
>>
>> and maybe if asset_itemid is not always unique
>>
>>      <prim-key field="depid"/>
>>
>> -----Original Message-----
>> From: Nattanicha Rittammanart [mailto:[hidden email]]
>> Sent: Sunday, April 20, 2008 1:38 PM
>> To: [hidden email]
>> Subject: Query entity
>>
>>
>>
>>    
>>> Hi all,
>>>  I have a problem to ask you.
>>>  I have table like this:
>>>
>>> <entity package-name="org.ofbiz.ams.ams"
>>> entity-name="DepreciationTrans" title="Keeps depreication record from
>>> depreciation table which created in each period">
>>>        <field type="id-ne" name="asset_itemid"></field>
>>>        <field type="id-ne" name="depid"/>
>>>        <field type="id" name="account_no"/>
>>>        <field type="currency-amount" name="value_before_cal"/>
>>> </entity>
>>>
>>> I want to show it by using form, I do like this:
>>>
>>> <form name="ShowDepreTables" type="list" list-name="depre_to_dates"
>>> paginate-target="ShowDepreTable">
>>>        <actions>
>>>            <entity-condition entity-name="DepreciationTrans"><order-by
>>> field-name="calculate_date"/></entity-condition>
>>>        </actions>
>>>        <field name="asset_itemid" title="asset
>>>      
>> itemid"><display/></field>
>>    
>>>        <field name="depid" title="department id"><display/></field>
>>>        <field name="account_no" title="account
>>>      
>> number"><display/></field>
>>    
>>>        <field name="value_before_cal" title="before
>>> price"><display/></field>
>>> </form>
>>>
>>> But asset_itemid is a field which link from another table. If I show
>>> table as above, it will show asset_itemid. What I want is, I need it
>>> to show asset_item_name. So, I do like this:
>>>
>>> ......
>>>        <field name="asset_itemid" title="asset item name">
>>>            <display-entity entity-name="AssetItems"
>>> description="${asset_item_desc}"
>>> key-field-name="asset_itemid"></display-entity>
>>>        </field>
>>> ......
>>>
>>> But it caused error like this
>>>
>>> org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
>>> [component://ams/widget/common/CommonScreens.xml#GlobalDecorator]:
>>> java.lang.IllegalArgumentException: Error getting value from the
>>> database for display of field [asset_itemid] on form
>>> [ShowDepreTables]: org.ofbiz.entity.GenericModelException:
>>> [GenericDelegator.findOne] Passed primary key is not a valid primary
>>> key:
>>>
>>>      
>> [GenericEntity:AssetItems][asset_itemid,08000200010002(java.lang.String)]
>>    
>>> (Error getting value from the database for display of field
>>> [asset_itemid] on form [ShowDepreTables]:
>>> org.ofbiz.entity.GenericModelException: [GenericDelegator.findOne]
>>> Passed primary key is not a valid primary key:
>>>
>>>      
>> [GenericEntity:AssetItems][asset_itemid,08000200010002(java.lang.String)])
>>    
>>> How can I do to link asset_item_name from another table to show in
>>> table which has asset_itemid??
>>>
>>> Thank in advances,
>>> Nattanicha
>>>
>>>      
>> No virus found in this incoming message.
>> Checked by AVG.
>> Version: 7.5.524 / Virus Database: 269.23.0/1381 - Release Date: 4/16/2008
>> 9:34 AM
>>
>> No virus found in this outgoing message.
>> Checked by AVG.
>> Version: 7.5.524 / Virus Database: 269.23.0/1381 - Release Date: 4/16/2008
>> 9:34 AM
>>
>>
>>    
>
>
>