[Hibernate-JIRA] Created: (HHH-2920) Polymorphic association with explicit table_per_class strategy: properties of subclass are not retrieved by queries.
by Andrea Silva (JIRA)
Polymorphic association with explicit table_per_class strategy: properties of subclass are not retrieved by queries.
--------------------------------------------------------------------------------------------------------------------
Key: HHH-2920
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2920
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.5
Environment: Java 1.5 - Hypersonic DB - Standalone application
Reporter: Andrea Silva
Priority: Minor
Attachments: src.zip
Item class has a one-to-many association to Bid. Bid class has a subclass called CashBid (meaningless design I know, but that's not the point). If I create and save an instance of Item with an associated CashBid, when I query for items the properties defined in CashBid are not retrieved.
NB Bid is not mapped as abstract.
Here is a code snippet:
...
// First Session
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
Bid bid = new CashBid(new BigDecimal(100.0d), "euro");
Item item = new Item("pc");
Serializable bidId = session.save(bid);
item.addBid(bid);
session.save(item);
transaction.commit();
session.close();
// Second Session
session = sessionFactory.openSession();
transaction = session.beginTransaction();
//session.load(CashBid.class, bidId);
Query query = session.createQuery("from Item");
List<Item> list = query.list();
for (Item item_ : list) {
System.out.println(item_);
}
transaction.commit();
session.close();
...
The bid in the item retrieved by the query is a CashBid (that's correct) but the properties that are defined in CashBid and not in Bid are null. If I uncomment the line
//session.load(CashBid.class, bidId);
the problem is not there anymore.
If Bid is not mapped as abstract the problem doesn't show.
My apologies if I'm just missing something very obvious.
Please find the source code and the mappings attached.
--
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
17 years, 1 month
[Hibernate-JIRA] Created: (HSHARDS-58) Increase power of ShardResolutionStrategy interface by passing the object itself ...
by Colbert Philippe (JIRA)
Increase power of ShardResolutionStrategy interface by passing the object itself ...
------------------------------------------------------------------------------------
Key: HSHARDS-58
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSHARDS-58
Project: Hibernate Shards
Issue Type: Improvement
Reporter: Colbert Philippe
Assignee: Max Ross
Interface ShardResolutionStrategy has a single method to determine what the list of shard indexes where an object might be located. Unfortunately, the method is passed only the 1) entity name and 2) the object id that we need to be saved.
I find that this is too limiting. The method should pass the object itself that we need to determine the list of shards. Passing the object itself would give much more programming possibilities.
An example of that is the following: I am persisting a class called User. My shard strategy saves User objects according to their home state. The attribute home state in located in the object itself. We know that the US has 50 states. Some states are much bigger than others. My application has several shards for bigger states. In order to determine the set of shards where a User object might be located, it is critical that I have the home state where the User resides.
SOLUTION: Class ShardResolutionStrategyData should also have a new attribute with the instance of the object for which we want to determine the set of shards where the object might be located.
--
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
17 years, 1 month
[Hibernate-JIRA] Commented: (HHH-817) Aggregate projection aliases should not be applied to where-clause
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-817?page=co... ]
Gail Badner commented on HHH-817:
---------------------------------
Another fix is proposed in HHH-3371.
> Aggregate projection aliases should not be applied to where-clause
> ------------------------------------------------------------------
>
> Key: HHH-817
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5
> Environment: Oracle 9.2.0.6, Hibernate 3.0.5, Spring Framework 1.2.2 based application working on Jakarta Tomcat 5.0.28
> Reporter: Michal Jastak
> Priority: Minor
> Attachments: HHH-817.patch
>
>
> following java code:
> protected Entity loadEntityLightweight(Serializable entityId) throws DataAccessException {
> Criteria criteria = getSession().createCriteria(Entity.class);
> ProjectionList projectionList = Projections.projectionList();
> projectionList.add(Property.forName(BaseEntity.PROP_ID), BaseEntity.PROP_ID);
> projectionList.add(Property.forName(BaseEntity.PROP_TYPE), BaseEntity.PROP_TYPE);
> criteria.setProjection(projectionList);
> criteria.add(Restrictions.eq(BaseEntity.PROP_ID, entityId));
> criteria.setResultTransformer(new AliasToBeanResultTransformer(Entity.class));
> return (Entity) criteria.uniqueResult();
> }
> generates following SQL query:
> select this_.id as y0_, this_.type as y1_ from entities this_ left outer join facilities this_1_ on this_.id=this_1_.id left outer join users this_2_ on this_.id=this_2_.id left outer join addresses address2_ on this_.address_id=address2_.id left outer join entities entity3_ on this_2_.employer_id=entity3_.id left outer join facilities entity3_1_ on entity3_.id=entity3_1_.id left outer join users entity3_2_ on entity3_.id=entity3_2_.id where y0_=?
> y0_ = ? expression in where clause is causing a 904 error on Oracle 9:
> ORA-00904: "Y0_": invalid identifier
> hibernate dialect: org.hibernate.dialect.Oracle9Dialect
> mapping for Entity class:
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping default-lazy="false" default-cascade="save-update">
>
> <class name="Entity" table="entities" mutable="true">
> <id name="id" type="java.lang.Long" unsaved-value="null">
> <generator class="sequence">
> <param name="sequence">entities_id_seq</param>
> </generator>
> </id>
> <many-to-one name="address" class="Address" column="address_id" />
> ...
> <!--
> - Facilities
> -->
> <joined-subclass name="Facility" table="facilities">
> <key column="id" />
> ...
> <set name="users" inverse="true" lazy="true">
> <key column="facility_id" />
> <one-to-many class="User" />
> </set>
> </joined-subclass>
> <!--
> - Users
> -->
> <joined-subclass name="User" table="users" dynamic-insert="true" dynamic-update="true">
> <key column="id" />
> <many-to-one name="employer" class="Entity" column="employer_id" cascade="none" />
> ...
> <set name="userAuthorities" inverse="true" cascade="all-delete-orphan">
> <key column="user_id" />
> <one-to-many class="Authority" />
> </set>
> </joined-subclass>
> </class>
> </hibernate-mapping>
--
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
17 years, 1 month
[Hibernate-JIRA] Created: (HHH-3546) invalid sql when using projection and restriction
by Martin Trummer (JIRA)
invalid sql when using projection and restriction
--------------------------------------------------
Key: HHH-3546
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3546
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: MS SQL Server/HSQLDB
Reporter: Martin Trummer
from this forum "discussion" (in fact it's a monologue): http://forum.hibernate.org/viewtopic.php?p=2398068#2398068
* the criteria
Criteria criteria = getActorDao().createCriteria();
criteria.add(Restrictions.or(
Restrictions.ilike("name", "adi"),
Restrictions.ilike("description", "adi")
));
criteria.setProjection(Projections.projectionList()
.add(Projections.groupProperty("name"), "name")
.add(Projections.groupProperty("description"), "description")
);
criteria.setResultTransformer(new AliasToBeanResultTransformer(ActorTestDTO.class));
List result = criteria.list();
* the generated SQL (show_sql=true):
select this_.name as y0_, this_.description as y1_
from Actor this_
left outer join Action this_1_ on this_.id=this_1_.id
left outer join Location this_2_ on this_.id=this_2_.id
left outer join UserGroup this_3_ on this_.id=this_3_.id
left outer join WebUser this_4_ on this_.id=this_4_.id
where (lower(y0_) like ? or lower(y1_) like ?)
group by this_.name, this_.description
* the Problem
This generated SQL works on HSQLDB but NOT on MS-SqlServer.
The wrong code:
where (lower(y0_) like ? or lower(y1_) like ?)
The correct code:
where (lower(this_.name) like ? or lower(this_.description) like ?)
I verified this by issuing the sql directly in SQL-server.
--
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
17 years, 1 month
[Hibernate-JIRA] Created: (BVAL-15) Object graph traversed too many times
by Emmanuel Bernard (JIRA)
Object graph traversed too many times
-------------------------------------
Key: BVAL-15
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-15
Project: Bean Validation
Issue Type: Bug
Components: ri-general
Reporter: Emmanuel Bernard
Assignee: Hardy Ferentschik
You seem to traverse the object graph once per group.
I made the spec so that multiple traversals were not necessary unless you physically force group sequence.
Actually the prototype I gave you was doing some clever things to minimize the number of
AFAIR I made the spec so that this multiple traversals are not needed unless you physically sequenciate them. In a prototype I had, I actually worked on an algorithm to validate as much groups as possible in a same traversal. Unfortunately I lost it, probably in my hardware crash :(
The idea was to compute a tree of groups to validate with their respective sequential constraints and run as less cycle as possible at a given time
e=|- a - b (b seq after a)
f=|- c - d (d seq after c)
validating e, f would run a and c in // in the same cycle and b and d in the second cycle.
--
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
17 years, 1 month