Hi Johan.
You are trying to squeeze too much data into one little field!
Typically, this happens when you use the default deployment for a String
field or similar for a bean which stores strings too long for the table.
Check the default type mappings in
[orion]/config/database-schemas/ms-sql.xml. You should see a line like:
<type-mapping type="java.lang.String" name="nvarchar(50)" />
If you need a particular field to be wider than this, you have two options:
1) Change the figure here, but this will be a global change so it will
affect all of your tables.
2) In the orion-ejb-jar.xml for your bean, add the line:
<cmp-field-mapping name="nameOfWideField"
persistence-type="nvarchar(100)" />
(or however wide you need) inside the appropriate <entity-deployment>
tag. Then drop the table and redeploy the jar. This will change the
mapping just for that field.
Or in your setter code, you can check the length of the string and truncate
it there if it is too long, or throw an exception.
Cheers,
Dan.
At 16:20 10/05/2001 +0200, you wrote:
>Why does MsSQL server complain about truncating data?
>
>com.jnetdirect.jsql.m: String or binary data would be truncated.
> at com.jnetdirect.jsql.af.a(Unknown Source)
> at com.jnetdirect.jsql.w.a(Unknown Source)
> at com.jnetdirect.jsql.w.a(Unknown Source)
> at com.jnetdirect.jsql.w.executeQuery(Unknown Source)
> at com.jnetdirect.jsql.z.executeQuery(Unknown Source)
> at com.evermind._oj.executeQuery(Unknown Source)
> at
> se.flowinteractive.aller.bean.ImageHandler.saveImage(ImageHandler.java:528)
> at
>
>__jspPage6_test_imgadmin_image_save_jsp._jspService(__jspPage6_test_imgadmin_image_save_jsp.java:74)
> at com.orionserver.http.OrionHttpJspPage.service(Unknown Source)
> at com.evermind._aj._nxd(Unknown Source)
> at com.evermind.server.http.JSPServlet.service(Unknown Source)
> at com.evermind._iib._vfd(Unknown Source)
> at com.evermind._iib._qjc(Unknown Source)
> at com.evermind._kj._qbc(Unknown Source)
> at com.evermind._kj._oa(Unknown Source)
> at com.evermind._jw.run(Unknown Source)
>I'm using a setString on a varchar(5)
>
>Is this not legal?
>
>(yes I know this is not orionspecific, and therefore I should not ask this
>question here, but there are a lot of bright people out there who might
>have ran into this before and can give me a quick solution.)
>
>Johan
--
Dan North
Support Team - Cadrion Consulting Ltd - +44 (0)20 7440 9550
CONFIDENTIALITY
This e-mail and any attachments are confidential
and may also be privileged. If you are not the named recipient,
please notify the sender immediately and do not disclose the
contents to another person, use it for any purpose, or store
or copy the information in any medium