Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Having issues with fields coming back trimmed in DB2

I am having some issues setting this in my code –

((org.eclipse.persistence.internal.jpa.EntityManagerImpl)this.em.getDelegate()).getSession().getLogin().setShouldTrimStrings(false);

I am getting a nullpointer when it does the getSession.

 

From the examples I have seen online it looks right, I have also tried getActiveSession() and getServerSession() without success.

 

Thanks

 

Sirius Computer Solutions


Kevin Haskett |  Application Developer Architect  |   402-965-2372 |  Cell: 402-290-2855
Fax: 402-965-2414
  |   E-mail: kevin.haskett@xxxxxxxxxxxxx

14301 First National Parkway - Suite 400, Omaha, NE 68154


National Technology Solutions Provider
www.siriuscom.com

 

From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Christopher Delahunt
Sent: Friday, April 01, 2011 8:41 AM
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] Having issues with fields coming back trimmed in DB2

 

Hello,

James explained a similar issue here:
http://stackoverflow.com/questions/4706102/jpa-discriminator-column-problem

Though it was for a querying on descriminator fields, the problem is the same.  A solution provided was to call
session.getLogin().setShouldTrimStrings(false);
which is described here:
http://wiki.eclipse.org/Configuring_a_Database_Login_(ELUG)#How_to_Configure_Advanced_Options_Using_Java

If this doesn't work, what is the database field type?

Regards,
Chris




On 31/03/2011 4:20 PM, Kevin Haskett wrote:

The DescVal fields are getting truncated…

 

If I run this query in Squirrel

select  classcd, descval1, length(trim(descval1)), length(descval1) from gndata.zdk01genlf

 

I get

CLASSCD   DESCVAL1                                                                  Trim Len      Untrim Len

91177          Auctioneers - sales conducted away from    39                 40

 

But when I look at the results in my app it shows DESCVAL1 as unTrimmed length of 39.

 

Thanks

 

 

From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Christopher Delahunt
Sent: Thursday, March 31, 2011 3:12 PM
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] Having issues with fields coming back trimmed in DB2

 

Hello Kevin,

Only thing I can think of is that you are persisting strings which are longer than the field definitions you have provided on your columns and DB2 might be silently truncating them.  But you have not said what is getting trimmed, or what the values are in the database.

Best Regards,
Chris

On 31/03/2011 4:06 PM, Kevin Haskett wrote:

I am executing a query and I am getting trimmed values back in my String fields. 

Here is what I have been using  -

 

@Entity

@Table(name = "ZDK01GENLF", schema = "GNDATA")

public class Zdk01genlf implements Serializable {

 

    @Column(name = "DESCVAL1", unique = true, nullable = false, length = 40)

    private String descval1;

 

    @Column(name = "DESCVAL2", unique = true, nullable = false, length = 40)

    private String descval2;

 

    @Column(name = "PREMBASE", unique = true, nullable = false, length = 2)

    private String premiumBase;

 

    @Column(name = "EXPBASE", unique = true, nullable = false, length = 5)

    private String exposureBase;

 

    @Column(name = "PREMSUBLN", unique = true, nullable = false, length = 3)

    private String premiseOpsCovSubline;

 

    // Fields

    @EmbeddedId

    private Zdk01genlfId id;

 

 

@Embeddable

public class Zdk01genlfId implements Serializable {

 

    @Transient

    private static final long serialVersionUID = 8557988537944379720L;

 

    // Fields

    @Column(name = "CLASSCD", unique = true, nullable = false, length = 8)

    private String classcd;

    @Column(name = "EFFDATE", unique = true, nullable = false, length = 8)

   private String effdate;

    @Column(name = "EXFDATE", unique = true, nullable = false, length = 8)

    private String expdate;

 

}

 

And I execute this -

 

queryString = SELECT model FROM Zdk01genlf model  WHERE UPPER(TRIM(FROM model.id.classcd)) LIKE :propertyValue and 20110331 >= model.id.effdate and 20110331 <= model.id.expdate order by model.descval1

 

From -

final Query query = this.em.createQuery(queryString);

            query.setParameter("propertyValue", value);

return query.getResultList();

 

Any ideas why the values are trimmed? 

 

Thanks,

Kevin

 

This message (including any attachments) is intended only for the use of the individual or entity to which it is addressed and may contain information that is non-public, proprietary, privileged, confidential, and exempt from disclosure under applicable law or may constitute as attorney work product. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, notify us immediately by telephone and (i) destroy this message if a facsimile or (ii) delete this message immediately if this is an electronic communication. Thank you.

 

 
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
  

This message (including any attachments) is intended only for the use of the individual or entity to which it is addressed and may contain information that is non-public, proprietary, privileged, confidential, and exempt from disclosure under applicable law or may constitute as attorney work product. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, notify us immediately by telephone and (i) destroy this message if a facsimile or (ii) delete this message immediately if this is an electronic communication. Thank you.

 

 
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
  

This message (including any attachments) is intended only for the use of the individual or entity to which it is addressed and may contain information that is non-public, proprietary, privileged, confidential, and exempt from disclosure under applicable law or may constitute as attorney work product. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, notify us immediately by telephone and (i) destroy this message if a facsimile or (ii) delete this message immediately if this is an electronic communication. Thank you.


Back to the top