Problem with DB2 [message #390043] |
Fri, 10 July 2009 17:20 |
Ajay Kumar 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 #390293 is a reply to message #390285] |
Thu, 16 July 2009 14:00 |
|
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 |
Ajay Kumar 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 #553538 is a reply to message #550893] |
Tue, 17 August 2010 20:38 |
Blair 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04861 seconds