[Hibernate-JIRA] Commented: (HHH-1851) relax special handling of 'id' property
by Sanne Grinovero (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1851?page=c... ]
Sanne Grinovero commented on HHH-1851:
--------------------------------------
please have Projections.id() return the identifier, whatever it is called.
> relax special handling of 'id' property
> ---------------------------------------
>
> Key: HHH-1851
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1851
> Project: Hibernate Core
> Issue Type: Improvement
> Components: query-hql
> Environment: independent, all versions all databases.
> Reporter: Gunther Schadow
> Assignee: Steve Ebersole
> Fix For: 3.5
>
> Attachments: IdClassAndAnotherPropertyNamedId.zip
>
>
> Hibernate has long treated 'id' in a special manner in HQL and Criteria queries. The drawback to this has always been that it effectively means users cannot define non-identifier properties named id and refer to those properties in HQL/Criteria queries.
> Thus, I will change this such that:
> (1) 'id' can still be used to refer to the identifier property, whatever the property's actual name, as long as the entity does not define a non-identitifer property named id.
> (2) if the entity defines a non-identifier property named 'id', using 'id' in HQL or Criteria queries will refer to this non-identifier property; users would need to refer to the identifier property by its actual name.
> FYI, the original reason for this feature was to support entity's which did not define an identifier property at all (users were responsible for managing the ids seperately. That feature was never really recommended and has been deprecated since early in the 3.x development.
--
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
15 years, 10 months
[Hibernate-JIRA] Created: (ANN-836) Availability of @CollectionId in Maps
by Vlasov Igor (JIRA)
Availability of @CollectionId in Maps
----------------------------------------
Key: ANN-836
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-836
Project: Hibernate Annotations
Issue Type: Improvement
Affects Versions: 3.4.0.GA
Reporter: Vlasov Igor
Hello, I have table
user(
id number(10)
name varchar(50)
)
and table
user_right(
id number(10)
name varchar(50)
key varchar(50)
)
then i want to tie together "user" and "user_right" in table:
rl_user_right(
rl_id number(10)
usr_id number(10)
ur_id number(10)
)
I can do this in such manner
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "rl_user_right",
joinColumns = @JoinColumn(name = "usr_id"),
inverseJoinColumns = @JoinColumn(name = "ur_id"))
@CollectionId(columns = @Column(name = "rl_id"),
type = @org.hibernate.annotations.Type(type = "long"), generator = "identity")
@org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
private List<UserRight> rights;
BUT i want to have property of Map type : private Map<String,UserRight> rights; with "key" value =user_right.key
I try to do :
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "rl_user_right",
joinColumns = @JoinColumn(name = "usr_id"),
inverseJoinColumns = @JoinColumn(name = "ur_id"))
@javax.persistence.MapKey(name="ur_key")
@CollectionId(columns = @Column(name = "rl_id"),
type = @org.hibernate.annotations.Type(type = "long"), generator = "identity")
@org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
private Map<String,UserRight> rights;
Then i catch an exception Map do not support @CollectionId: com.entity.User.rights;
org.hibernate.cfg.annotations.CollectionBinder.getCollectionBinder
.....
if ( java.util.Map.class.equals( returnedClass ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) {
throw new AnnotationException( "Map do not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) );
}
return new MapBinder();
}
How can I achieve my desire with another way?
May be allow @CollectionId in Maps?
--
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
15 years, 10 months
[Hibernate-JIRA] Created: (EJB-439) Query.getSingleResult fails if a sored proc is used
by Lloyd Fernandes (JIRA)
Query.getSingleResult fails if a sored proc is used
---------------------------------------------------
Key: EJB-439
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-439
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.4.0.GA
Environment: Hibernate core 3.3.1
Reporter: Lloyd Fernandes
If you use Query.getSingleResult() on a named query that results in a stored proce call, the query is changed from
{call usp_RequestState_Get (:requestID ) }
to
{call usp_RequestState_Get (? ) }
to
{call usp_Requ top 2estState_Get (? ) } in (org.hibernate.loader.Loader.prepareQueryStatement() line 1557)
Code was working for 3.3.2
Looks like this was broken/incorrectly implemented earlier (than 3.3.2) but exasperated by the recent change to org.hibernate.ejb.QueryImpl.getSingleResult() that forces a maxResult to 2.
I think the correct fix will be to not insert the limit statement (Loader.java line 15557) if the sql query does not start with a select call or if it is marked callable
--
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
15 years, 10 months
[Hibernate-JIRA] Created: (ANN-835) ManyToMany from and to the same object by using a non primary key column
by Frank Pfleger (JIRA)
ManyToMany from and to the same object by using a non primary key column
------------------------------------------------------------------------
Key: ANN-835
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-835
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.4.0.GA
Environment: Core 3.3.1.GA, Annotations 3.4.0, Postgres 8.3, JBoss 4.2.3 JDK6, Seam 2.1.1.GA
Reporter: Frank Pfleger
A ManyToMany relationship to the same table and the same property produces a MappingException on JBoss startup.
Caused by: org.hibernate.MappingException: Duplicate property mapping of _org_weazel_security_entity_impl_Group_groups found in org.weazel.security.entity.impl.Group
at org.hibernate.mapping.PersistentClass.checkPropertyDuplication(PersistentClass.java:477)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:467)
at org.hibernate.mapping.RootClass.validate(RootClass.java:215)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1135)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1320)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
... 145 more
An Example Annotation that works fine between different tables and objects (NUMBER is a non primary key column/property)
@ManyToMany
@JoinTable(joinColumns=@JoinColumn(name="NUMBER1", referencedColumnName="NUMBER")),
inverseJoinColumns=@JoinColumn(name="NUMBER2", referencedColumnName="NUMBER"))
Using this Annotation between different classes works fine as said before.
The Problem is the syntheticPropertyName (_org_weazel_security_entity_impl_Group_groups) generated in BinderHelper.createSyntheticPropertyReference which is the same for both parts/ends of the ManyToMany relationship.
--
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
15 years, 10 months