[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-4364) Support @NamedQuery on a @MappedSuperclass (Sharath Reddy)
Sharath Reddy (JIRA)
noreply at atlassian.com
Thu Oct 1 15:29:53 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sharath Reddy updated HHH-4364:
-------------------------------
Attachment: HHH-4364.patch
This patch has nothing to do with emdebbed classes; only mapped superclasses.
I have done quite a bit of testing, and even if several entities inherit from the MappedSuperClass that contains the query, the MappedSuperClass is only passed once to the method 'bindClass' for processing. Also attached a patch that verifies this.
I think this issue can be resolved.
> Support @NamedQuery on a @MappedSuperclass (Sharath Reddy)
> ----------------------------------------------------------
>
> Key: HHH-4364
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4364
> Project: Hibernate Core
> Issue Type: Improvement
> Components: annotations
> Environment: INFO Version:15 - Hibernate Annotations 3.2.1.GA
> 09:15:01,755 INFO Environment:500 - Hibernate 3.2.1
> INFO SettingsFactory:81 - RDBMS: Microsoft SQL Server, version: 08.00.0760
> 09:15:06,114 INFO SettingsFactory:82 - JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.2
> 09:15:06,255 INFO Dialect:151 - Using dialect: org.hibernate.dialect.SQLServerDialect
> Reporter: Steve Ebersole
> Assignee: Emmanuel Bernard
> Fix For: 3.5
>
> Attachments: ANN-593.patch, BaseUser.java, HHH-4364.patch, TestUserService.java, User.java, UserService.java
>
> Original Estimate: 4 hours
> Remaining Estimate: 4 hours
>
> If I use a @MappedSuperclass (which is a very useful annotation btw) I have to manually copy any queries I want with taht class up to all subclasses. The binder should check any mapped superclasses and pull those named queries up. i.e.
> /**
> * Base User class that different projects user classes derive from.
> * Hibernate annotations doesn't pick up that query, so you have to copy it up to your subclass
> */
> @MappedSuperclass
> @NamedQueries({
> @NamedQuery(name="User.findByLoginName",
> query="FROM User WHERE loginName = ?") // this is useless down here, i just put it here for reference
> })
> public class BaseUser<PK extends Serializable> extends IdEntity<PK> {
> private static final long serialVersionUID = -4443522925041212381L;
> protected String loginName;
>
> @Column(unique=true)
> public String getLoginName() {
> return this.loginName;
> }
> public void setLoginName(String loginName) {
> this.loginName = loginName;
> }
> }
> /**
> * Custom user class for a certain application
> */
> @Entity
> @Table(name="tbl_user")
> @GenericGenerator(name=IdGen.NAME, strategy=IdGen.AUTO)
> @NamedQueries({
> @NamedQuery(name="User.findByLoginName",
> query="FROM User WHERE loginName = ?") // had to copy this up from the base class
> })
> public class User extends BaseUser<Short> {
> private static final long serialVersionUID = -6199544722824321999L;
> private String firstName;
> ...
> }
> so in short it would be nice if the scanner would check for that and bind any named queries up to the subclass
--
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list