Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problem with DB2
Problem with DB2 [message #390043] Fri, 10 July 2009 17:20 Go to next message
Ajay Kumar is currently offline Ajay KumarFriend
Messages: 13
Registered: July 2009
Junior Member
We have one more problem in the area of the JPA as such in eclipse link.
We are using DB2 server as back end and simple JPA query we are running.



Query is

SELECT v.schemaId, v.vuiId, v.vuiType, v.locale, d.label, d.propShort,
d.propLong FROM VUIEntity v, VuiDisppropEntity d WHERE (d.vuiId = v.vuiId)
AND (d.schemaId = v.schemaId) AND (d.fieldId = 0) ORDER BY v.schemaId



Works on two simple tables



One of the table looks like


RECORDID
INTEGER
4
No


SCHEMAID
INTEGER
4
No


FIELDID
INTEGER
4
No


LISTINDEX
INTEGER
4
No


VUIID
INTEGER
4
No


"LABEL"
VARCHAR
254
Yes


PROPSHORT
VARCHAR
4000
Yes


PROPLONG
CLOB
10485760
Yes


SRVPROPSHORT
VARCHAR
255
Yes


SRVPROPLONG
CLOB
10485760
Yes







And in the entity definition

This FIELDID field is treated as integer.





For some reason the eclipse link is generating query like

SELECT t0.SCHEMAID, t0.VUIID, t0.VUITYPE, t0.LOCALE, t1.LABEL,
t1.PROPSHORT, t1.PROPLONG FROM vui t0, field_dispprop t1 WHERE
((((t1.VUIID = t0.VUIID) AND (t1.SCHEMAID = t0.SCHEMAID)) AND (t1.FIELDID
= '0')) AND (t1.FIELDID = '0')) ORDER BY t0.SCHEMAID ASC



t1.FIELDID = '0' à gets rejected by the DB2 server as this is not a
character field.



This issue is blocking us.
Re: Problem with DB2 [message #390054 is a reply to message #390043] Mon, 13 July 2009 14:21 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Please include your mappings/class annotations.

It looks like you have a class using inheritance, and have to set
EclipseLink to use an Integer discriminator column, so it is using
character (default).

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: Problem with DB2 [message #390285 is a reply to message #390054] Mon, 13 July 2009 17:40 Go to previous messageGo to next message
Ajay Kumar is currently offline Ajay KumarFriend
Messages: 13
Registered: July 2009
Junior Member
changed the inheritance as following still no luck

@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "FIELDID", discriminatorType =
DiscriminatorType.INTEGER)

Added the following part

discriminatorType = DiscriminatorType.INTEGER) --> in the entity
relationship.

Thx
Ajay
Re: Problem with DB2 [message #390293 is a reply to message #390285] Thu, 16 July 2009 14:00 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

It should be bound as an Integer if you have correctly set the type. Make
sure you have recompiled/deployed your code with the change.

You can inspect the discriminators using,

session.getDescriptor(YourClass.class).getInheritancePolicy( ).getClassIndicatorMapping()

The values should be an Integer in the Map.


James : Wiki : Book : Blog : Twitter
Re: Problem with DB2 --- Urgent [message #390300 is a reply to message #390293] Fri, 17 July 2009 06:01 Go to previous messageGo to next message
Ajay Kumar is currently offline Ajay KumarFriend
Messages: 13
Registered: July 2009
Junior Member
James,
I checked and fieldid is defined as integer with size 4. Here is my
mapping for the given table

----
@Entity
@Table(name = "field_dispprop")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "FIELDID", discriminatorType =
DiscriminatorType.INTEGER, length = 4)
@DiscriminatorValue(value = "0")
public class VuiDisppropEntity {

private Integer recordId;
----

Here is the snippet for the filed_dispprop

----
@Entity
@Table(name = "field_dispprop")
public class FieldDisppropEntity {

protected Integer recordId;

@Id
protected Integer schemaId;

@Id
protected Integer vuiId;

@Id
protected Integer fieldId;

@Id
protected Integer listIndex;
protected String label;
protected String propShort;
protected String propLong;
protected String srvPropShort;
protected String srvPropLong;

@SuppressWarnings("unused")
@ManyToOne
@JoinColumns(value = {
@JoinColumn(name = "schemaId", referencedColumnName =
"SCHEMAID", insertable = false, updatable = false),
@JoinColumn(name = "fieldId", referencedColumnName =
"FIELDID", insertable = false, updatable = false, columnDefinition = "INT
NOT NULL") })

------

works fine for the sql server.

But giving problem on DB2.

We are completely blocked by this. Please suggest a way to solve this
problem.

Thx
Ajay
Re: Problem with DB2 --- Urgent [message #547415 is a reply to message #390300] Fri, 16 July 2010 17:01 Go to previous messageGo to next message
Blair  is currently offline Blair Friend
Messages: 6
Registered: July 2010
Junior Member
Was there ever any resolution to this problem? I've spent a frustrating 4 days trying to resolve it, and as far as I can see I'm doing things correctly but the underlying code insists on treating the discriminator type as String, not integer. I'm about to give up and ask our DBA to convert the column to varchar, but it *should work*!
Re: Problem with DB2 --- Urgent [message #550893 is a reply to message #547415] Wed, 04 August 2010 15:05 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

What version are you using?

Did you inspect the discriminators using,

session.getDescriptor(YourClass.class).getInheritancePolicy( ).getClassIndicatorMapping()

What values are there, Integer or String?

Include the SQL, and you mapping.


James : Wiki : Book : Blog : Twitter
Re: Problem with DB2 --- Urgent [message #553538 is a reply to message #550893] Tue, 17 August 2010 20:38 Go to previous messageGo to next message
Blair  is currently offline Blair Friend
Messages: 6
Registered: July 2010
Junior Member
Hi James, I gave up and had the DB values converted to use strings, but I was able to duplicate the problem with another table.

I'm using EclipseLink version 1.1.0. The class indicator mapping is showing values of "1" for my DaRemoveOverride class, and "0" for DaNoneOverride. Both values are java.lang.String.

My parent DaNoneOverride class is defined as:

@Entity
@Name("daNoneOverride")
@Table(schema="SCHEMA", name="DA_OVERRIDE")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="OVERRIDE_TYPE", discriminatorType=DiscriminatorType.INTEGER)
@DiscriminatorValue(value="0")
public class DaNoneOverride extends DaItem implements Serializable {

// SESSION_CD CHAR(6)
@Column(name="SESSION_CD", nullable=false, length=6)
private String sessionCode;

/**
* Retrieves the <i>sessionCode</i> property.
*
* @return The current value of the <i>sessionCode</i> property
* @see #setSessionCode
*/
@Length(max=6)
public String getSessionCode () {
return sessionCode;
}

/**
* Sets the <i>sessionCode</i> property.
*
* @param aString The new value for the <i>sessionCode</i> property
* @see #getSessionCode
*/
public void setSessionCode (String aString) {
sessionCode = aString;
}
}

The child DaRemoveOverride class:

@Entity
@Name("daRemoveOverride")
@DiscriminatorValue(value = "1")
public class DaRemoveOverride extends DaNoneOverride implements Serializable {

/**
* Default constructor.
*/
public DaRemoveOverride () {
super();
}

}

Finally, the generated SQL:

SELECT ID, OVERRIDE_TYPE, SESSION_CD, LAST_CHANGED_TS, VERSION, LAST_CHANGED_BY FROM SCHEMA.DA_OVERRIDE WHERE (OVERRIDE_TYPE = '1')

The quotes around the '1' are of course the problem, which is probably related to the String values in the mapping.

Blair


Re: Problem with DB2 --- Urgent [message #554635 is a reply to message #553538] Mon, 23 August 2010 19:18 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

In looking at the code, it seems to be a bug.

Please log the bug and vote for it.

A workaround other than using String, is to use a DescriptorCustomizer to convert the ClassDescriptor's InheritancePolicy classIndicatorMapping from String to Integer.



James : Wiki : Book : Blog : Twitter
Re: Problem with DB2 --- Urgent [message #556020 is a reply to message #554635] Mon, 30 August 2010 14:47 Go to previous message
Blair  is currently offline Blair Friend
Messages: 6
Registered: July 2010
Junior Member
Bug 323975 created, although it may be related to bug 303770.

Blair
Previous Topic:get original Object state from Session
Next Topic:Calculated Primary Key
Goto Forum:
  


Current Time: Thu Apr 25 07:47:34 GMT 2024

Powered by FUDForum. Page generated in 0.03569 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top