Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Rewati Raman
feild creation inside entity in service.xml
September 5, 2012 10:11 PM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

Hi everyone,

Is there any way that we can create the feilds in entity with datatype blob or other datatype apart from boolean,collection,String,long,int,double,Date.

Thanks in Advance
Rewati Raman
Harish Kumar
RE: feild creation inside entity in service.xml
September 5, 2012 10:57 PM
Answer

Harish Kumar

Rank: Expert

Posts: 327

Join Date: July 31, 2010

Recent Posts

Hi Rewati

You can do so by specifying this in portlet-model-hints.xml file. for example to use CLOB you can do

 1
 2<field name="content" type="String">
 3<hint-collection name="CLOBTYPE" />
 4</field>
 5
 6
 7<hint-collection name="CLOBTYPE">
 8<hint name="max-length">2000000</hint>
 9</hint-collection>


HTH
Regards,
Rewati Raman
RE: feild creation inside entity in service.xml
September 5, 2012 11:04 PM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

HI Harish,

But while creation of service builder we use to write column instead of feild in entity while writin the obove codes it is throwing error
Harish Kumar
RE: feild creation inside entity in service.xml
September 5, 2012 11:10 PM
Answer

Harish Kumar

Rank: Expert

Posts: 327

Join Date: July 31, 2010

Recent Posts

Yes in service.xml we will specify the columns as usual. Here is full example for your reference -

sample service.xml snippet -

 1
 2<entity name="Foo" local-service="true" remote-service="true">
 3
 4        <!-- PK fields -->
 5
 6        <column name="fooId" type="long" primary="true" />
 7
 8        <column name="userId" type="long" />
 9        <column name="userName" type="String" /> // will use CLOB for this column
10       
11</entity>


and here is portlet-model-hints.xml snippet. you can find this file in WEB-INF/src/META-INF

 1
 2<model-hints>
 3    <model name="com.harish.sample.model.Foo">
 4        <field name="fooId" type="long" />
 5        <field name="userId" type="long" />
 6        <field name="userName" type="String">
 7            <hint-collection name="CLOBTYPE" />
 8        </field>
 9    </model>
10    <hint-collection name="CLOBTYPE">
11        <hint name="max-length">2000000</hint>
12    </hint-collection>
13</model-hints>


check the column datatype in DB before and after making this change


Regards,
Rewati Raman
RE: feild creation inside entity in service.xml
September 5, 2012 11:24 PM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

Hi Harish,

Thanks for quick Reply
Rewati Raman
RE: feild creation inside entity in service.xml
September 5, 2012 11:37 PM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

Hi Harish

I am not able to find the portlet-model-hints.xml in WEB-INF/src/META-INF
Pls healp me out in that

Regards,
Rewati Raman
Harish Kumar
RE: feild creation inside entity in service.xml
September 5, 2012 11:50 PM
Answer

Harish Kumar

Rank: Expert

Posts: 327

Join Date: July 31, 2010

Recent Posts

you can find this file on this path \<<your-portlet>>\docroot\WEB-INF\src\META-INF\portlet-model-hints.xml
Rewati Raman
RE: feild creation inside entity in service.xml
September 6, 2012 12:11 AM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

sorry Harish but in my portlet under src im not having META-INF it is outside and it contains only manifest.mf file
im sending my project stucture
Attachment

Attachments: Screenshot.png (93.9k)
Harish Kumar
RE: feild creation inside entity in service.xml
September 6, 2012 12:18 AM
Answer

Harish Kumar

Rank: Expert

Posts: 327

Join Date: July 31, 2010

Recent Posts

have you run the build-service target for your portlet. Please run the build service
Rewati Raman
RE: feild creation inside entity in service.xml
September 6, 2012 12:24 AM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

thanks harish got the file now ill try for the database

Regards,
Rewati Raman
Rewati Raman
RE: feild creation inside entity in service.xml
September 6, 2012 10:53 PM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

Hi harish,

Thanks It Workedemoticon

Regards,
Rewati Raman
Haris Tasawar
RE: feild creation inside entity in service.xml
January 29, 2013 8:49 AM
Answer

Haris Tasawar

Rank: Junior Member

Posts: 35

Join Date: June 4, 2012

Recent Posts

Hey guys,
I tried the same thing, but i am still getting the error:
ORA-00932: inconsistent datatypes: expected - got CLOB

here is my portlet-model-hints.xml file:

<?xml version="1.0"?>

<model-hints>
<model name="searchmeeting.model.category">
<field name="CATEGORYID" type="long" />
<field name="CATEGORYNAME" type="String" />
<field name="CATEGORYDESCRIPTION" type="String" />
<field name="GROUPID" type="long" />
</model>
<model name="searchmeeting.model.meetingminutes">
<field name="uuid" type="String" />
<field name="M_ID" type="long" />
<field name="MEETING_NO" type="String" />
<field name="MEETING_DATE" type="String" />
<field name="MINUTES" type="String">
<hint-collection name="CLOBTYPE" />
</field>
<field name="STATUS" type="int" />
<field name="STATUSBYUSERID" type="long" />
<field name="STATUSBYUSERNAME" type="String" />
<field name="STATUSDATE" type="Date" />
<field name="GROUPID" type="long" />
<field name="COMPANYID" type="long" />
<field name="USERID" type="long" />
<field name="MINUTESSTATUS" type="String" />
<field name="CATEGORY" type="String" />
</model>
<hint-collection name="CLOB">
<hint name="max-length">2000000</hint>
</hint-collection>
</model-hints>


Please i also tried to run the service builder after i modified this but still the same problem emoticon
Siby Mathew
RE: feild creation inside entity in service.xml
January 29, 2013 8:57 AM
Answer

Siby Mathew

Rank: Expert

Posts: 261

Join Date: March 4, 2011

Recent Posts

Hi Haris,
I think the hint-collection names need to match.
In your case "CLOBTYPE" and "CLOB". Just try it out !

Thanks,
Siby