openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Gajdos (JIRA)" <j...@apache.org>
Subject [jira] Updated: (OPENJPA-249) problem using enum with @Enumerated annotation in Query
Date Fri, 01 Jun 2007 12:44:15 GMT

     [ https://issues.apache.org/jira/browse/OPENJPA-249?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Daniel Gajdos updated OPENJPA-249:
----------------------------------

    Description: 
Situation description:
@Entity
public class Application {
...
	@ManyToOne(optional = false)
	@JoinColumn(name = "C_APPLICATION_STATUS",
		nullable = false)
	private ApplicationStatus applicationStatus;
...}

@Entity
public class ApplicationStatus {
	public static enum Code {
		created
	}
	@Id
	@Column(name = "C_CODE")
	@Enumerated(EnumType.STRING)
	private Code code;
}
And now the problem:
When executing query "SELECT a FROM Application a WHERE a.applicationStatus = :status" with
parameter q.setParameter("status", ApplicationStatus status); everything works fine. 
But when trying to call the query like "SELECT a FROM Application a WHERE a.applicationStatus.code
= :package.ApplicationStatus.Code.created " it fails with: Attempt to query field "package.ApplicationStatus.Code.waiting"
from non-entity class "null".
Is there any way to create a query with built in enum value? I found a similar issue on http://forums.oracle.com/forums/thread.jspa?threadID=506389&tstart=45

  was:
Situation description:
@Entity
public class Application {
...
	@ManyToOne(optional = false)
	@JoinColumn(name = "C_APPLICATION_STATUS",
		nullable = false)
	@ForeignKey(name = "FK_APPLICATION__APPLICATION_S")
	private ApplicationStatus applicationStatus;
...}

@Entity
public class ApplicationStatus {
	public static enum Code {
		created
	}
	@Id
	@Column(name = "C_CODE")
	@Enumerated(EnumType.STRING)
	private Code code;
}
And now the problem:
When executing query "SELECT a FROM Application a WHERE a.applicationStatus = :status" with
parameter q.setParameter("status", ApplicationStatus status); everything works fine. 
But when trying to call the query like "SELECT a FROM Application a WHERE a.applicationStatus.code
= :package.ApplicationStatus.Code.created " it fails with: Attempt to query field "package.ApplicationStatus.Code.waiting"
from non-entity class "null".
Is there any way to create a query with built in enum value? I found a similar issue on http://forums.oracle.com/forums/thread.jspa?threadID=506389&tstart=45


> problem using enum with @Enumerated annotation in Query
> -------------------------------------------------------
>
>                 Key: OPENJPA-249
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-249
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: query
>    Affects Versions: 0.9.7
>         Environment: Windows XP, WAS 6.1
>            Reporter: Daniel Gajdos
>
> Situation description:
> @Entity
> public class Application {
> ...
> 	@ManyToOne(optional = false)
> 	@JoinColumn(name = "C_APPLICATION_STATUS",
> 		nullable = false)
> 	private ApplicationStatus applicationStatus;
> ...}
> @Entity
> public class ApplicationStatus {
> 	public static enum Code {
> 		created
> 	}
> 	@Id
> 	@Column(name = "C_CODE")
> 	@Enumerated(EnumType.STRING)
> 	private Code code;
> }
> And now the problem:
> When executing query "SELECT a FROM Application a WHERE a.applicationStatus = :status"
with parameter q.setParameter("status", ApplicationStatus status); everything works fine.

> But when trying to call the query like "SELECT a FROM Application a WHERE a.applicationStatus.code
= :package.ApplicationStatus.Code.created " it fails with: Attempt to query field "package.ApplicationStatus.Code.waiting"
from non-entity class "null".
> Is there any way to create a query with built in enum value? I found a similar issue
on http://forums.oracle.com/forums/thread.jspa?threadID=506389&tstart=45

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message