[Hibernate-JIRA] Created: (HHH-3655) Select Query Using JPA and Static Inner Class
by Caine Lai (JIRA)
Select Query Using JPA and Static Inner Class
---------------------------------------------
Key: HHH-3655
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3655
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.1
Environment: Hibernate Version 3.3.1 GA, using JPA. MySQL DB.
Reporter: Caine Lai
Attachments: HibernateStaticInnerClassBug.zip
I want to collect some statistics using JPA and return them all as a value object to my web tier. In my value object I have a static inner class I would like to use for the JPA query.
My Class:
public class GeneralVendorStatsVO {
private List<StatusCounts> statusCounts = new ArrayList<StatusCounts>();
/**
* Inner class for holding status counts for vendors.
*/
public static class StatusCounts {
private UserStatus status;
private Long count;
public StatusCounts(UserStatus status, Long count) {
this.status = status;
this.count = count;
}
public UserStatus getStatus() { return status; }
public void setStatus(UserStatus status) { this.status = status; }
public Long getCount() { return count; }
public void setCount(Long count) { this.count = count; }
}
// ********************** Accessor Methods ********************** //
public List<StatusCounts> getStatusCounts() { return statusCounts; }
public void setStatusCounts(List<StatusCounts> statusCounts) { this.statusCounts = statusCounts; }
}
And here is the method I am trying to execute:
public GeneralVendorStatsVO getGeneralVendorStats() {
GeneralVendorStatsVO vo = new GeneralVendorStatsVO();
// Get the status counts.
String queryString = "SELECT new vo.stats.vendor.GeneralVendorStatsVO.StatusCounts(user.status, count(user)) FROM User user GROUP BY user.status";
Query query = this.em.createQuery(queryString);
List<GeneralVendorStatsVO.StatusCounts> statusCounts = query.getResultList();
vo.setStatusCounts(statusCounts);
for (GeneralVendorStatsVO.StatusCounts entry : statusCounts) {
log.debug("Status: " + entry.getStatus()+ "Count: " + entry.getCount());
}
return vo;
}
The error:
org.hibernate.hql.ast.QuerySyntaxException: Unable to locate class [vo.stats.vendor.GeneralVendorStatsVO.StatusCounts]
I don't know why this would not work, when I can do:
new GeneralVendorStatsVO.StatusCounts(UserStatus.APPROVED, 200L)
I was told I should open an issue because it seems like a bug. More info here: http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=78...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (METAGEN-77) Inheritance of metamodel classes
by Peter Dragula (JIRA)
Inheritance of metamodel classes
---------------------------------
Key: METAGEN-77
URL: http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-77
Project: Hibernate Metamodel Generator
Issue Type: Bug
Components: processor
Affects Versions: 1.1.1.Final
Environment: hibernate 3.6.7, oracle 11g
Reporter: Peter Dragula
Assignee: Hardy Ferentschik
Priority: Minor
If there is Inheritance structure like:
@Entity (No entity annotation) @Entity
public class Party extends public abstract Timelimited extends public abstract Versioned
String name Long timelimitedId Long versionedId
Date date
Long partyId
the model generator generates Party_ with only name date and partyid (no extends )
then it generates Timelimited_ with timelimitedId , but also without any parents (no extends)
and lastly a Versioned_ is generated with versionedId
Now I would like to say Party_.versionedId , but i cant
A workaround is to annotate the Timelimited class (which is in the middle of the hierarchy) with a @Entity
then the Party_ extends Timelimited which extends Versioned and everything works as desired
but JPA allows to have non entity classes in the middle of a hierarchy :
Both abstract and concrete classes can be entities. Both abstract and concrete classes can be annotated with the Entity annotation, mapped as entities, and queried for as entities.
Entities can extend non-entity classes and non-entity classes can extend entity classes:
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (METAGEN-75) Maven plugin and JPA XML configuration path problem
by Nickolay Mazurkin (JIRA)
Maven plugin and JPA XML configuration path problem
---------------------------------------------------
Key: METAGEN-75
URL: http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-75
Project: Hibernate Metamodel Generator
Issue Type: Bug
Components: processor
Affects Versions: 1.1.1.Final
Environment: Ubuntu, Maven 2, Java 6
Reporter: Nickolay Mazurkin
Assignee: Hardy Ferentschik
I have a problem with generating metamodel from JPA configuation
I have JPA config like the following - there are a lot of ORM mapping in relative subdirectories
<persistence-unit name="ApplicationDataSource" transaction-type="RESOURCE_LOCAL">
<description>Main persistence descriptor</description>
<mapping-file>configuration/model/jpa/mappings/base.xml</mapping-file>
<mapping-file>configuration/model/jpa/mappings/entities/employer.xml</mapping-file>
<mapping-file>configuration/model/jpa/mappings/entities/unit/unit.xml</mapping-file>
...
<mapping-file>configuration/model/jpa/mappings/entities/unit/maintenance.xml</mapping-file>
</persistence-unit>
The problem is that processor is not able to find all these mappings without trailing slash. The following config works with metamodel processor
<persistence-unit name="ApplicationDataSource" transaction-type="RESOURCE_LOCAL">
<!-- with trailing slash -->
<mapping-file>/configuration/model/jpa/mappings/base.xml</mapping-file>
</persistence-unit>
But the trailing slash doesn't allow the config to be loaded by Hibernate org.hibernate.ejb.Ejb3Configuration - Hibernate fails to load the config with trailing slash
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (METAGEN-73) Refactoring of the Generated annotation
by Théo Chamley (JIRA)
Refactoring of the Generated annotation
---------------------------------------
Key: METAGEN-73
URL: http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-73
Project: Hibernate Metamodel Generator
Issue Type: Improvement
Affects Versions: 1.2.next
Reporter: Théo Chamley
Assignee: Hardy Ferentschik
Priority: Minor
Attachments: hibernate-jpamodelgen-refactoring-generated-annotation.diff
You will find as an attached file a patch to modify the Generated annotation of the JPA MetaModels.
The value element of the annotation is now the name of the processor.
If activated, the annotation as an element date which that indicates when the file has been generated. This element date may be a problem when you try to compare several generated files, so you can remove it with the option -AremoveDateFromGeneratedAnnotation=true.
Hope this helps,
--
Théo
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months