This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 226450

Summary: Parsing of named queries doesn't work for enums
Product: javaee Reporter: mienamoo
Component: PersistenceAssignee: Sergey Petrov <sj-nb>
Status: VERIFIED WORKSFORME    
Severity: normal    
Priority: P3    
Version: 7.3   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

Description mienamoo 2013-02-21 10:38:43 UTC
NetBeans build 201302132200
JDK 7u13 64-bit

The IDE is not able to resolved enums when used in named queries, and will display a warning on the entity even though it works perfectly when the query is executed.
Comment 1 Sergey Petrov 2013-02-21 10:41:32 UTC
Can you provide sample query?
Comment 2 cdelahunt 2013-02-21 10:58:26 UTC
Hi,

Please see an example of the problem below.


We have a class Customer which has a named query that uses the CustomerStatus
enum in the where clause to filter on customer statuses.

Customer.java

package com.hello.customer;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.NamedQuery;

@Entity
@NamedQuery(name = "Customer.findByStatus", query = "SELECT c FROM Customer c
WHERE c.customerStatus = com.hello.customer.CustomerStatus.ACTIVE")
public class Customer implements Serializable {

    @Id
    private int id;
    private String name;
    @Enumerated(EnumType.STRING)
    private CustomerStatus customerStatus;
}



CustomerStatus.java

package com.hello.customer;

public enum CustomerStatus {
    INAVCTIVE, ACTIVE
}



Netbeans show the following warning for the named query
"Customer.findByStatus":

Customer.findByStatus[50;90]: The state field path
'com.hello.customer.CustomerStatus.ACTIVE' cannot be resolved to a valid type.

Customer.findByStatus[50;53]: The identification variable 'com' is not defined
in the FROM clause.


Hope this helps.
Comment 3 Sergey Petrov 2013-03-19 18:03:21 UTC
thanks, seems to be resolved in latest builds. at least I can't reproduce with suggested sample.
Comment 4 mienamoo 2013-03-22 07:09:53 UTC
Verified with build 201303212300.