You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Giuseppe De Rosa <gi...@gmail.com> on 2020/10/31 14:51:01 UTC
Issue java.io.StreamCorruptedException
I'm trying to make a simple select query but receive this error:
java.io.StreamCorruptedException: invalid stream header: 78780A1F
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:857)
In datamap I have a db-attribute of type CLOB that I want read as a simple String.
<db-entity name="DISC">
<db-attribute name="DATE" type="TIMESTAMP" isMandatory="true" length="7"/>
<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
<db-attribute name="FLAG" type="VARCHAR" isMandatory="true"/>
<db-attribute name="REQUEST" type="CLOB" isMandatory="false"/>
<db-key-generator>
<db-generator-type>ORACLE</db-generator-type>
<db-generator-name>DISC_SEQ</db-generator-name>
<db-key-cache-size>1</db-key-cache-size>
</db-key-generator>
</db-entity>
<obj-entity name="Disc" className="it.pack.dao.Disc" dbEntityName="DISC">
<obj-attribute name="date" type="java.time.LocalDateTime" db-attribute-path="DATE"/>
<obj-attribute name="id" type="java.lang.Integer" db-attribute-path="ID"/>
<obj-attribute name="flag" type="java.lang.String" db-attribute-path="FLAG"/>
<obj-attribute name="request" type="java.lang.String" db-attribute-path="REQUEST"/>
</obj-entity>
I think that CLOB cannot map to java.lang.String but how can I read it?
Re: Issue java.io.StreamCorruptedException
Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi there,
I suspect this has nothing to do with CLOB and String. It may be other attributes. So a few questions:
1. What version of Cayenne is this?
2. Do you have a longer stack trace?
3. Could you check the logs preceding the exception for messages like "Haven't found suitable ExtendedType for class..."
Andrus
> On Oct 31, 2020, at 5:51 PM, Giuseppe De Rosa <gi...@gmail.com> wrote:
>
> I'm trying to make a simple select query but receive this error:
>
> java.io.StreamCorruptedException: invalid stream header: 78780A1F
> at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:857)
>
> In datamap I have a db-attribute of type CLOB that I want read as a simple String.
>
> <db-entity name="DISC">
> <db-attribute name="DATE" type="TIMESTAMP" isMandatory="true" length="7"/>
> <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
> <db-attribute name="FLAG" type="VARCHAR" isMandatory="true"/>
> <db-attribute name="REQUEST" type="CLOB" isMandatory="false"/>
> <db-key-generator>
> <db-generator-type>ORACLE</db-generator-type>
> <db-generator-name>DISC_SEQ</db-generator-name>
> <db-key-cache-size>1</db-key-cache-size>
> </db-key-generator>
> </db-entity>
> <obj-entity name="Disc" className="it.pack.dao.Disc" dbEntityName="DISC">
> <obj-attribute name="date" type="java.time.LocalDateTime" db-attribute-path="DATE"/>
> <obj-attribute name="id" type="java.lang.Integer" db-attribute-path="ID"/>
> <obj-attribute name="flag" type="java.lang.String" db-attribute-path="FLAG"/>
> <obj-attribute name="request" type="java.lang.String" db-attribute-path="REQUEST"/>
> </obj-entity>
>
> I think that CLOB cannot map to java.lang.String but how can I read it?
Re: Issue java.io.StreamCorruptedException
Posted by Giuseppe De Rosa <gi...@gmail.com>.
Ok, the modeler now changed generated classes:
public void setRequestSd(CharType requestSd) {
writeProperty(REQUEST_SD, requestSd);
}
public CharType getRequestSd() {
return (CharType)readProperty(REQUEST_SD);
}
Now how to convert a String that I want to store in a CharType?
On 2020/11/01 14:01:31, Amedeo Mantica <am...@me.com.INVALID> wrote:
> No. Never edit the generated classes.
> You can set the mapped class in the modeler.
>
> Sent from my iPhone
>
> > On 1 Nov 2020, at 14:30, Giuseppe De Rosa <gi...@gmail.com> wrote:
> >
> > So I need to modify the generated class, right? Actually for clob field I have this situation:
> >
> > public void setRequest(String request) {
> > writeProperty(REQUEST, request);
> > }
> >
> > public String getRequest() {
> > return (String)readProperty(REQUEST);
> > }
> >
> > How to change it?
> >
> >> On 2020/10/31 15:33:57, Amedeo Mantica <am...@me.com.INVALID> wrote:
> >> I guess you should map it as
> >>
> >> org.apache.cayenne.access.types.CharType
> >>
> >> Amedeo
> >>
> >>>> On 31 Oct 2020, at 15:51, Giuseppe De Rosa <gi...@gmail.com> wrote:
> >>>
> >>> I'm trying to make a simple select query but receive this error:
> >>>
> >>> java.io.StreamCorruptedException: invalid stream header: 78780A1F
> >>> at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:857)
> >>>
> >>> In datamap I have a db-attribute of type CLOB that I want read as a simple String.
> >>>
> >>> <db-entity name="DISC">
> >>> <db-attribute name="DATE" type="TIMESTAMP" isMandatory="true" length="7"/>
> >>> <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
> >>> <db-attribute name="FLAG" type="VARCHAR" isMandatory="true"/>
> >>> <db-attribute name="REQUEST" type="CLOB" isMandatory="false"/>
> >>> <db-key-generator>
> >>> <db-generator-type>ORACLE</db-generator-type>
> >>> <db-generator-name>DISC_SEQ</db-generator-name>
> >>> <db-key-cache-size>1</db-key-cache-size>
> >>> </db-key-generator>
> >>> </db-entity>
> >>> <obj-entity name="Disc" className="it.pack.dao.Disc" dbEntityName="DISC">
> >>> <obj-attribute name="date" type="java.time.LocalDateTime" db-attribute-path="DATE"/>
> >>> <obj-attribute name="id" type="java.lang.Integer" db-attribute-path="ID"/>
> >>> <obj-attribute name="flag" type="java.lang.String" db-attribute-path="FLAG"/>
> >>> <obj-attribute name="request" type="java.lang.String" db-attribute-path="REQUEST"/>
> >>> </obj-entity>
> >>>
> >>> I think that CLOB cannot map to java.lang.String but how can I read it?
> >>
> >>
>
Re: Issue java.io.StreamCorruptedException
Posted by Amedeo Mantica <am...@me.com.INVALID>.
No. Never edit the generated classes.
You can set the mapped class in the modeler.
Sent from my iPhone
> On 1 Nov 2020, at 14:30, Giuseppe De Rosa <gi...@gmail.com> wrote:
>
> So I need to modify the generated class, right? Actually for clob field I have this situation:
>
> public void setRequest(String request) {
> writeProperty(REQUEST, request);
> }
>
> public String getRequest() {
> return (String)readProperty(REQUEST);
> }
>
> How to change it?
>
>> On 2020/10/31 15:33:57, Amedeo Mantica <am...@me.com.INVALID> wrote:
>> I guess you should map it as
>>
>> org.apache.cayenne.access.types.CharType
>>
>> Amedeo
>>
>>>> On 31 Oct 2020, at 15:51, Giuseppe De Rosa <gi...@gmail.com> wrote:
>>>
>>> I'm trying to make a simple select query but receive this error:
>>>
>>> java.io.StreamCorruptedException: invalid stream header: 78780A1F
>>> at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:857)
>>>
>>> In datamap I have a db-attribute of type CLOB that I want read as a simple String.
>>>
>>> <db-entity name="DISC">
>>> <db-attribute name="DATE" type="TIMESTAMP" isMandatory="true" length="7"/>
>>> <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
>>> <db-attribute name="FLAG" type="VARCHAR" isMandatory="true"/>
>>> <db-attribute name="REQUEST" type="CLOB" isMandatory="false"/>
>>> <db-key-generator>
>>> <db-generator-type>ORACLE</db-generator-type>
>>> <db-generator-name>DISC_SEQ</db-generator-name>
>>> <db-key-cache-size>1</db-key-cache-size>
>>> </db-key-generator>
>>> </db-entity>
>>> <obj-entity name="Disc" className="it.pack.dao.Disc" dbEntityName="DISC">
>>> <obj-attribute name="date" type="java.time.LocalDateTime" db-attribute-path="DATE"/>
>>> <obj-attribute name="id" type="java.lang.Integer" db-attribute-path="ID"/>
>>> <obj-attribute name="flag" type="java.lang.String" db-attribute-path="FLAG"/>
>>> <obj-attribute name="request" type="java.lang.String" db-attribute-path="REQUEST"/>
>>> </obj-entity>
>>>
>>> I think that CLOB cannot map to java.lang.String but how can I read it?
>>
>>
Re: Issue java.io.StreamCorruptedException
Posted by Giuseppe De Rosa <gi...@gmail.com>.
So I need to modify the generated class, right? Actually for clob field I have this situation:
public void setRequest(String request) {
writeProperty(REQUEST, request);
}
public String getRequest() {
return (String)readProperty(REQUEST);
}
How to change it?
On 2020/10/31 15:33:57, Amedeo Mantica <am...@me.com.INVALID> wrote:
> I guess you should map it as
>
> org.apache.cayenne.access.types.CharType
>
> Amedeo
>
> > On 31 Oct 2020, at 15:51, Giuseppe De Rosa <gi...@gmail.com> wrote:
> >
> > I'm trying to make a simple select query but receive this error:
> >
> > java.io.StreamCorruptedException: invalid stream header: 78780A1F
> > at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:857)
> >
> > In datamap I have a db-attribute of type CLOB that I want read as a simple String.
> >
> > <db-entity name="DISC">
> > <db-attribute name="DATE" type="TIMESTAMP" isMandatory="true" length="7"/>
> > <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
> > <db-attribute name="FLAG" type="VARCHAR" isMandatory="true"/>
> > <db-attribute name="REQUEST" type="CLOB" isMandatory="false"/>
> > <db-key-generator>
> > <db-generator-type>ORACLE</db-generator-type>
> > <db-generator-name>DISC_SEQ</db-generator-name>
> > <db-key-cache-size>1</db-key-cache-size>
> > </db-key-generator>
> > </db-entity>
> > <obj-entity name="Disc" className="it.pack.dao.Disc" dbEntityName="DISC">
> > <obj-attribute name="date" type="java.time.LocalDateTime" db-attribute-path="DATE"/>
> > <obj-attribute name="id" type="java.lang.Integer" db-attribute-path="ID"/>
> > <obj-attribute name="flag" type="java.lang.String" db-attribute-path="FLAG"/>
> > <obj-attribute name="request" type="java.lang.String" db-attribute-path="REQUEST"/>
> > </obj-entity>
> >
> > I think that CLOB cannot map to java.lang.String but how can I read it?
>
>
Re: Issue java.io.StreamCorruptedException
Posted by Amedeo Mantica <am...@me.com.INVALID>.
I guess you should map it as
org.apache.cayenne.access.types.CharType
Amedeo
> On 31 Oct 2020, at 15:51, Giuseppe De Rosa <gi...@gmail.com> wrote:
>
> I'm trying to make a simple select query but receive this error:
>
> java.io.StreamCorruptedException: invalid stream header: 78780A1F
> at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:857)
>
> In datamap I have a db-attribute of type CLOB that I want read as a simple String.
>
> <db-entity name="DISC">
> <db-attribute name="DATE" type="TIMESTAMP" isMandatory="true" length="7"/>
> <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
> <db-attribute name="FLAG" type="VARCHAR" isMandatory="true"/>
> <db-attribute name="REQUEST" type="CLOB" isMandatory="false"/>
> <db-key-generator>
> <db-generator-type>ORACLE</db-generator-type>
> <db-generator-name>DISC_SEQ</db-generator-name>
> <db-key-cache-size>1</db-key-cache-size>
> </db-key-generator>
> </db-entity>
> <obj-entity name="Disc" className="it.pack.dao.Disc" dbEntityName="DISC">
> <obj-attribute name="date" type="java.time.LocalDateTime" db-attribute-path="DATE"/>
> <obj-attribute name="id" type="java.lang.Integer" db-attribute-path="ID"/>
> <obj-attribute name="flag" type="java.lang.String" db-attribute-path="FLAG"/>
> <obj-attribute name="request" type="java.lang.String" db-attribute-path="REQUEST"/>
> </obj-entity>
>
> I think that CLOB cannot map to java.lang.String but how can I read it?