[hibernate-issues] [Hibernate-JIRA] Updated: (ANN-593) Ability for an @NamedQuery on a @MappedSuperclass to be copied up to the subclass
John Newman (JIRA)
noreply at atlassian.com
Mon Apr 9 10:16:05 EDT 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-593?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Newman updated ANN-593:
----------------------------
Attachment: BaseUser.java
> Ability for an @NamedQuery on a @MappedSuperclass to be copied up to the subclass
> ---------------------------------------------------------------------------------
>
> Key: ANN-593
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-593
> Project: Hibernate Annotations
> Issue Type: Improvement
> Components: binder
> Affects Versions: 3.2.1
> 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: John Newman
> Attachments: BaseUser.java, 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