You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Joanna Chan <jo...@discoveryconsulting.com.au> on 2015/11/03 07:33:32 UTC
Issue filtering in Olingo by timestamp
Hi Olingo Experts,
We have an oData feed built on Olingo where the filtering is working for
all field types except for date and timestamp. We are utilizing the Spring
framework, Maven and JPA. Below is an example of a POJO that is not
filtering correctly:
@Entity
@Table(name = "AUDIT_LOGS")
@Multitenant
@TenantDiscriminatorColumn(name = "TENANT_ID", length = 36)
public class AuditLog {
@Id
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JoinColumn(name = "TENANT_ID", updatable = false, insertable = false)
@ManyToOne
private TenantId tenant;
@Column(length = 1)
private String type;
@Column(length = 50)
private String shortMessage;
@Column(length = 500)
private String fullMessage;
@Temporal(TemporalType.TIMESTAMP)
private Date date;
private String userId;
private String userName;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public TenantId getTenant() {
return tenant;
}
public void setTenant(TenantId tenant) {
this.tenant = tenant;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getShortMessage() {
return shortMessage;
}
public void setShortMessage(String shortMessage) {
this.shortMessage = shortMessage;
}
public String getFullMessage() {
return fullMessage;
}
public void setFullMessage(String fullMessage) {
this.fullMessage = fullMessage;
}
public Date getDate() {
return (Date) date.clone();
}
public void setDate(Date date) {
this.date = (Date) date.clone();
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
The filter string that is being used is below:
<ServiceURL>/Schedules?$skip=0&$top=20&$filter=((Date eq
datetime%272015-10-20T03:59:20%27))&$inlinecount=allpages
The result is coming back empty even though there is a matching date. We
have not implemented any custom filtering so it should all be out of the
box filtering.
Any help would be great!
Regards,
Joanna
RE: Issue filtering in Olingo by timestamp
Posted by "V.A, Chandan" <ch...@sap.com>.
Hello Joanna,
Did you consider time zone conversions into account.
Thanks
Kind Regards
Chandan
From: Amend, Christian [mailto:christian.amend@sap.com]
Sent: Friday, November 6, 2015 3:20 PM
To: user@olingo.apache.org
Subject: RE: Issue filtering in Olingo by timestamp
Hi Joanna,
I suspect this is because you use the Date class in your POJO instead of the Calendar class. The Calendar class is the default for all temporal simple properties. So I assume that JPA can`t convert from Date to Calendar although the metadata might be built correctly.
Could you try to set the Calendar class as a return type and see if this works? If not it is always helpful to get a bit more knowledge where the error is happening. You can do this by enabling the debug support as described here: http://olingo.apache.org/doc/odata2/tutorials/debug.html
All I would need is the stacktrace to see where the conversion fails.
Also please have a look at your metadata document what Edm.Type the “date” property has and let me know.
Best Regards,
Christian
From: Joanna Chan [mailto:joanna.chan@discoveryconsulting.com.au]
Sent: Freitag, 6. November 2015 00:40
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: Issue filtering in Olingo by timestamp
Hi Christian,
Yes that's right, with a timestamp I get no result at all. With a temporal type date I get an error saying cannot convert between date and timestamp.
Regards,
Jo
On 6 November 2015 at 00:03, Amend, Christian <ch...@sap.com>> wrote:
Hi,
am I right in my assumption that you do not get an exception but just an empty entry/feed?
Best Regards,
Christian
From: Joanna Chan [mailto:joanna.chan@discoveryconsulting.com.au<ma...@discoveryconsulting.com.au>]
Sent: Dienstag, 3. November 2015 07:34
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Issue filtering in Olingo by timestamp
Hi Olingo Experts,
We have an oData feed built on Olingo where the filtering is working for all field types except for date and timestamp. We are utilizing the Spring framework, Maven and JPA. Below is an example of a POJO that is not filtering correctly:
@Entity
@Table(name = "AUDIT_LOGS")
@Multitenant
@TenantDiscriminatorColumn(name = "TENANT_ID", length = 36)
public class AuditLog {
@Id
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JoinColumn(name = "TENANT_ID", updatable = false, insertable = false)
@ManyToOne
private TenantId tenant;
@Column(length = 1)
private String type;
@Column(length = 50)
private String shortMessage;
@Column(length = 500)
private String fullMessage;
@Temporal(TemporalType.TIMESTAMP)
private Date date;
private String userId;
private String userName;
public long getId() {
return id;
}
public void setId(long id) {
this.id<http://this.id> = id;
}
public TenantId getTenant() {
return tenant;
}
public void setTenant(TenantId tenant) {
this.tenant = tenant;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getShortMessage() {
return shortMessage;
}
public void setShortMessage(String shortMessage) {
this.shortMessage = shortMessage;
}
public String getFullMessage() {
return fullMessage;
}
public void setFullMessage(String fullMessage) {
this.fullMessage = fullMessage;
}
public Date getDate() {
return (Date) date.clone();
}
public void setDate(Date date) {
this.date = (Date) date.clone();
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
The filter string that is being used is below:
<ServiceURL>/Schedules?$skip=0&$top=20&$filter=((Date eq datetime%272015-10-20T03:59:20%27))&$inlinecount=allpages
The result is coming back empty even though there is a matching date. We have not implemented any custom filtering so it should all be out of the box filtering.
Any help would be great!
Regards,
Joanna
RE: Issue filtering in Olingo by timestamp
Posted by "Amend, Christian" <ch...@sap.com>.
Hi Joanna,
I suspect this is because you use the Date class in your POJO instead of the Calendar class. The Calendar class is the default for all temporal simple properties. So I assume that JPA can`t convert from Date to Calendar although the metadata might be built correctly.
Could you try to set the Calendar class as a return type and see if this works? If not it is always helpful to get a bit more knowledge where the error is happening. You can do this by enabling the debug support as described here: http://olingo.apache.org/doc/odata2/tutorials/debug.html
All I would need is the stacktrace to see where the conversion fails.
Also please have a look at your metadata document what Edm.Type the “date” property has and let me know.
Best Regards,
Christian
From: Joanna Chan [mailto:joanna.chan@discoveryconsulting.com.au]
Sent: Freitag, 6. November 2015 00:40
To: user@olingo.apache.org
Subject: Re: Issue filtering in Olingo by timestamp
Hi Christian,
Yes that's right, with a timestamp I get no result at all. With a temporal type date I get an error saying cannot convert between date and timestamp.
Regards,
Jo
On 6 November 2015 at 00:03, Amend, Christian <ch...@sap.com>> wrote:
Hi,
am I right in my assumption that you do not get an exception but just an empty entry/feed?
Best Regards,
Christian
From: Joanna Chan [mailto:joanna.chan@discoveryconsulting.com.au<ma...@discoveryconsulting.com.au>]
Sent: Dienstag, 3. November 2015 07:34
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Issue filtering in Olingo by timestamp
Hi Olingo Experts,
We have an oData feed built on Olingo where the filtering is working for all field types except for date and timestamp. We are utilizing the Spring framework, Maven and JPA. Below is an example of a POJO that is not filtering correctly:
@Entity
@Table(name = "AUDIT_LOGS")
@Multitenant
@TenantDiscriminatorColumn(name = "TENANT_ID", length = 36)
public class AuditLog {
@Id
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JoinColumn(name = "TENANT_ID", updatable = false, insertable = false)
@ManyToOne
private TenantId tenant;
@Column(length = 1)
private String type;
@Column(length = 50)
private String shortMessage;
@Column(length = 500)
private String fullMessage;
@Temporal(TemporalType.TIMESTAMP)
private Date date;
private String userId;
private String userName;
public long getId() {
return id;
}
public void setId(long id) {
this.id<http://this.id> = id;
}
public TenantId getTenant() {
return tenant;
}
public void setTenant(TenantId tenant) {
this.tenant = tenant;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getShortMessage() {
return shortMessage;
}
public void setShortMessage(String shortMessage) {
this.shortMessage = shortMessage;
}
public String getFullMessage() {
return fullMessage;
}
public void setFullMessage(String fullMessage) {
this.fullMessage = fullMessage;
}
public Date getDate() {
return (Date) date.clone();
}
public void setDate(Date date) {
this.date = (Date) date.clone();
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
The filter string that is being used is below:
<ServiceURL>/Schedules?$skip=0&$top=20&$filter=((Date eq datetime%272015-10-20T03:59:20%27))&$inlinecount=allpages
The result is coming back empty even though there is a matching date. We have not implemented any custom filtering so it should all be out of the box filtering.
Any help would be great!
Regards,
Joanna
Re: Issue filtering in Olingo by timestamp
Posted by Joanna Chan <jo...@discoveryconsulting.com.au>.
Hi Christian,
Yes that's right, with a timestamp I get no result at all. With a temporal
type date I get an error saying cannot convert between date and timestamp.
Regards,
Jo
On 6 November 2015 at 00:03, Amend, Christian <ch...@sap.com>
wrote:
> Hi,
>
>
>
> am I right in my assumption that you do not get an exception but just an
> empty entry/feed?
>
>
>
> Best Regards,
>
> Christian
>
>
>
> *From:* Joanna Chan [mailto:joanna.chan@discoveryconsulting.com.au]
> *Sent:* Dienstag, 3. November 2015 07:34
> *To:* user@olingo.apache.org
> *Subject:* Issue filtering in Olingo by timestamp
>
>
>
> Hi Olingo Experts,
>
> We have an oData feed built on Olingo where the filtering is working for
> all field types except for date and timestamp. We are utilizing the Spring
> framework, Maven and JPA. Below is an example of a POJO that is not
> filtering correctly:
>
> @Entity
> @Table(name = "AUDIT_LOGS")
> @Multitenant
> @TenantDiscriminatorColumn(name = "TENANT_ID", length = 36)
> public class AuditLog {
> @Id
> @Column(name = "ID", nullable = false)
> @GeneratedValue(strategy = GenerationType.IDENTITY)
> private Long id;
> @JoinColumn(name = "TENANT_ID", updatable = false, insertable = false)
> @ManyToOne
> private TenantId tenant;
> @Column(length = 1)
> private String type;
> @Column(length = 50)
> private String shortMessage;
> @Column(length = 500)
> private String fullMessage;
> @Temporal(TemporalType.TIMESTAMP)
> private Date date;
> private String userId;
> private String userName;
>
> public long getId() {
> return id;
> }
>
> public void setId(long id) {
> this.id = id;
> }
>
> public TenantId getTenant() {
> return tenant;
> }
>
> public void setTenant(TenantId tenant) {
> this.tenant = tenant;
> }
>
> public String getType() {
> return type;
> }
>
> public void setType(String type) {
> this.type = type;
> }
>
> public String getShortMessage() {
> return shortMessage;
> }
>
> public void setShortMessage(String shortMessage) {
> this.shortMessage = shortMessage;
> }
>
> public String getFullMessage() {
> return fullMessage;
> }
>
> public void setFullMessage(String fullMessage) {
> this.fullMessage = fullMessage;
> }
>
> public Date getDate() {
> return (Date) date.clone();
> }
>
> public void setDate(Date date) {
> this.date = (Date) date.clone();
> }
>
> public String getUserId() {
> return userId;
> }
>
> public void setUserId(String userId) {
> this.userId = userId;
> }
>
> public String getUserName() {
> return userName;
> }
>
> public void setUserName(String userName) {
> this.userName = userName;
> }
>
> }
>
> The filter string that is being used is below:
> <ServiceURL>/Schedules?$skip=0&$top=20&$filter=((Date eq
> datetime%272015-10-20T03:59:20%27))&$inlinecount=allpages
>
> The result is coming back empty even though there is a matching date. We
> have not implemented any custom filtering so it should all be out of the
> box filtering.
>
> Any help would be great!
>
> Regards,
>
> Joanna
>
>
>
RE: Issue filtering in Olingo by timestamp
Posted by "Amend, Christian" <ch...@sap.com>.
Hi,
am I right in my assumption that you do not get an exception but just an empty entry/feed?
Best Regards,
Christian
From: Joanna Chan [mailto:joanna.chan@discoveryconsulting.com.au]
Sent: Dienstag, 3. November 2015 07:34
To: user@olingo.apache.org
Subject: Issue filtering in Olingo by timestamp
Hi Olingo Experts,
We have an oData feed built on Olingo where the filtering is working for all field types except for date and timestamp. We are utilizing the Spring framework, Maven and JPA. Below is an example of a POJO that is not filtering correctly:
@Entity
@Table(name = "AUDIT_LOGS")
@Multitenant
@TenantDiscriminatorColumn(name = "TENANT_ID", length = 36)
public class AuditLog {
@Id
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JoinColumn(name = "TENANT_ID", updatable = false, insertable = false)
@ManyToOne
private TenantId tenant;
@Column(length = 1)
private String type;
@Column(length = 50)
private String shortMessage;
@Column(length = 500)
private String fullMessage;
@Temporal(TemporalType.TIMESTAMP)
private Date date;
private String userId;
private String userName;
public long getId() {
return id;
}
public void setId(long id) {
this.id<http://this.id> = id;
}
public TenantId getTenant() {
return tenant;
}
public void setTenant(TenantId tenant) {
this.tenant = tenant;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getShortMessage() {
return shortMessage;
}
public void setShortMessage(String shortMessage) {
this.shortMessage = shortMessage;
}
public String getFullMessage() {
return fullMessage;
}
public void setFullMessage(String fullMessage) {
this.fullMessage = fullMessage;
}
public Date getDate() {
return (Date) date.clone();
}
public void setDate(Date date) {
this.date = (Date) date.clone();
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
The filter string that is being used is below:
<ServiceURL>/Schedules?$skip=0&$top=20&$filter=((Date eq datetime%272015-10-20T03:59:20%27))&$inlinecount=allpages
The result is coming back empty even though there is a matching date. We have not implemented any custom filtering so it should all be out of the box filtering.
Any help would be great!
Regards,
Joanna