[Hibernate-JIRA] Created: (HHH-4013) One-to-one:property-ref to a part of composite-key
by Sandeep Vaid (JIRA)
One-to-one:property-ref to a part of composite-key
--------------------------------------------------
Key: HHH-4013
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4013
Project: Hibernate Core
Issue Type: Improvement
Reporter: Sandeep Vaid
I have 2 classes viz. Product and ProductBasic having one-to-one relationship
Product is mapped to a table PRODUCT which has PRODUCTID as PK.
ProductBasic is mapped to a table PRODUCTBASIC which has PRODUCTID,USECODE and STARTTTIME as composite key.
My database is legacy and i cannot change it.
I get the one-to-one relationship by applying the condition as:
PRODUCT.PRODUCTID=PRODUCTBASIC.PRODUCTID and USECODE='008' and STARTTIME < CURRENTIME < ENDTIME..
My database values are such that if i apply this condition i will only get once record..
In Product.hbm.xml:
<class name="Product" table="PRODUCT"
<id name="pid" type="string" column="PRODUCTID" length="10">
<generator class="assigned"></generator>
</id>
<one-to-one name="productBasic" class="ProductBasic" constrained="true" outer-join="false" cascade="save-update" property-ref="activeProductBasic" >
<formula>PRODUCTID</formula>
</one-to-one>
</class>
In ProductBasic.hbm.xml
<class name="ProductBasic" table="PRODUCTBASIC">
<composite-id name="compProductBasic" class="CompProductRelatedAssociations">
<key-property name="productId" column="PRODUCTID" type="string" length="10" />
<key-property name="useCode" column="USECODE" type="string" length="10" />
<key-property name="startTime" column="STARTTIME" type="timestamp"/>
</composite-id>
<properties name="activeProductBasic">
<property name="compProductBasic.productId" column="PRODUCTID" type="string" length="10" insert="false" update="false"/>
</properties>
</class>
but this compProductBasic.productId is giving me error...
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-4012) Part of Composite-Id is foreign Key:How specify in Mapping?
by Sandeep Vaid (JIRA)
Part of Composite-Id is foreign Key:How specify in Mapping?
-----------------------------------------------------------
Key: HHH-4012
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4012
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.3.2
Reporter: Sandeep Vaid
Priority: Critical
I have 2 classes viz. Product and ProductBasic having one-to-one relationship
class Product{
String productId;
ProductBasic productBasic;
}
class ProductBasic{
String productId;
String useCode;
TimeStamp startTime;
Product product;
}
Product is mapped to a table PRODUCT which has PRODUCTID as PK.
ProductBasic is mapped to a table PRODUCTBASIC which has PRODUCTID,USECODE and STARTTTIME as composite key.
Also PRODUCTID (of PRODUCTBASIC table) is the foreign key referencing PRODUCT table...
How can i define my one-to-one mapping considering ProductBasic.productId should get its value from Product.productId ?
<composite-id>
<key-property name="productId" column="PRODUCTID" type="string" length="10" />
<key-property name="useCode" column="USECODE" type="string" length="10" />
<key-property name="startTime" column="STARTTIME" />
<composite-id>
In this only productId is the foreign key..
I am aware that i can use a <generator> tag (with class="foreign") inside <composite-id> but i guess it will generate the
value for entire composite-id and not just a field of it.
--
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, 6 months
[Hibernate-JIRA] Created: (HBX-812) Fetching Children of Database _crawls_.
by Syd Poetry (JIRA)
Fetching Children of Database _crawls_.
---------------------------------------
Key: HBX-812
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-812
Project: Hibernate Tools
Type: Bug
Components: reverse-engineer
Versions: 3.2beta8
Environment: MySQL 5.0, Eclipse 3.2, JDK 1.5, Beta8 for Hibernate Tools
Reporter: Syd Poetry
I just updated a bunch of components for Eclipse (mostly related to Visual Editor); added a couple of tables to my database, went to regenerate all the POJO clases .hbm.xml mapping files, and found that anything that queries the database schema runs abysmally slow.
Updated the tools from beta6 to beta8 thinking it might be a conflict with one of the updates that was performed, still very slow (5+ minutes to retrieve a list of tables!). Deleted all my hibernate-related XML files thinking it might be a parsing error, went to generate a new console file, and revenge.xml, found out that any listbox that tried to access the schema appeared to be hanging. It finishes after much hard-drive crunching. I have 2.2 GBs free running windows XP, MEM usage is 856 MB out of 1.5 GB physical memory. Just out of curiousity, is *anyone* else having this slow response for schema detection? I'm wondering if I have to update another component like a driver or something like that.
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-3362) NullPointerException in org.hibernate.dialect.Dialect$2.getReturnType
by Istvan Kovacs (JIRA)
NullPointerException in org.hibernate.dialect.Dialect$2.getReturnType
---------------------------------------------------------------------
Key: HHH-3362
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3362
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: Hibernate Core 3.6.2 GA, hsqldb
Reporter: Istvan Kovacs
Attachments: bug_src.zip
java.lang.NullPointerException
at org.hibernate.dialect.Dialect$2.getReturnType(Dialect.java:85)
at org.hibernate.hql.ast.util.SessionFactoryHelper.findFunctionReturnType(SessionFactoryHelper.java:382)
at org.hibernate.hql.ast.tree.AggregateNode.getDataType(AggregateNode.java:21)
at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:143)
at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:705)
at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:529)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:645)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at org.hibernate.console.HQLQueryPage.setSession(HQLQueryPage.java:106)
at org.hibernate.console.ConsoleConfiguration$4.execute(ConsoleConfiguration.java:388)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:383)
[...]
3 classes:
Employee: Long ID; String name; Shop shop
Shop: Long ID; String name; Set<Employee> employees; Map<Product, Integer> stock
Product: Long ID; String name
I mapped them to RDBMS using Hibernate. There's a table to hold stock info:
SHOP_PRODUCT_STOCK - has fields SHOP_ID, PRODUCT_ID, AMOUNT
SQL to query the average stock of each product:
select p.name as name, avg(sps.amount) as avg_stock
from Shop s, Shop_Product_Stock sps, Product p
where sps.product_id=p.product_id and sps.product_id=p.product_id
group by p.name
order by p.name;
Attempt in HQL that the produces exception:
select p, avg(s.stock[p])
from Shop s, Product p
group by p
I've also tried SELECTing and GROUPing BY p.id and p.name. None of the three variants work.
--
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, 6 months
[Hibernate-JIRA] Commented: (HHH-408) Implementation of E-QBE (Enhanced-QueryByExample) (CONTRIBUTION)
by tareq alhashash (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-408?page=co... ]
tareq alhashash commented on HHH-408:
-------------------------------------
great feature thank you,
i`v already tested it and its great, but i guess there is a problem in composite keys entities.
looking forward for its release.
> Implementation of E-QBE (Enhanced-QueryByExample) (CONTRIBUTION)
> ----------------------------------------------------------------
>
> Key: HHH-408
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-408
> Project: Hibernate Core
> Issue Type: New Feature
> Components: core
> Reporter: Marc Piparo
> Assignee: Gavin King
> Attachments: hibernate-eqbe.zip, hibernate-eqbe.zip, overview-summary.html
>
>
> Adds E-QBE (Enhanced-QueryByExample) functionality that dynamically builds criteria objects based on an example object graph, by traversing the entire object graph, building query criteria for the object's properties, as well as, properties of associated objects.
> Also adds the ability to apply an Evaluation group of "Evaluators" to properties using object dot notation to provide "where" restrictions on property values.
> Example usage:
> Given a typical Person and Address class relationship...
> >> Person person = new Person();
> >> person.setName("Marc");
> >> Address address = new Address();
> >> address.setCity("Orlando%");
> >> person.setAddress(address);
> >>
> >> Evaluation eval = new Evaluation();
> >> eval.addEvaluator("address.city", Evaluator.LIKE);
> >> // query for persons with name="Marc" that live in city starting
> >> // with "Orlando".
> >> List results = session.createEQBECriteria(people, eval).list()
> also....to apply "OR" condition on property value:
> >> a.setCity("Orlando||New York");
> package: org.hibernate.eqbe
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-4008) Hibernate may generate gap or duplicate list index when do cascade saveOrUpdate
by LC (JIRA)
Hibernate may generate gap or duplicate list index when do cascade saveOrUpdate
-------------------------------------------------------------------------------
Key: HHH-4008
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4008
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Environment: WindowsXP. Java 1.5.14. Spring 2.5.6, Junit 3.8.1. Sybase12.5
Reporter: LC
Priority: Blocker
Say we have ParentTable(p_id, etc) ChildTable(c_id, p_id, listindex)
Parent{
id
Arraylist children;
... properties
}
Child{
id
properties
}
mapping:
Parent.hbm.xml
<class name="Parent" table="ParentTable">
<id name="id" type="java.lang.Long">
<column name="p_id" />
<generator class="native" />
</id>
<list name="children" cascade="all-delete-orphan">
<key column="p_id" not-null="true" update="false"/>
<list-index>
<column name="list_index"/>
</list-index>
<one-to-many class="Child"/>
</list>
</class>
Child.hbm.xml
<class name="Child" table="ChildTable">
<id name="id" type="java.lang.Long">
<column name="c_id"/>
<generator class="native"/>
</id>
</class>
DAO
PDAO extends HibernateDaoSupport{
......
public void saveAndUpdate(Parent instance){
getHibernateTemplate().saveOrUpdate(instance);
}
......
}
Test case:
Parent p = new Parent();
p.setChildren(new Arraylist());
Child c1 = new Child();
Child c2 = new Child();
Child c3 = new Child();
Child c4 = new Child();
p.getChildren().add(c1);
p.getChildren().add(c2);
p.getChildren().add(c3);
p.getChildren().add(c4);
pDAO.saveAndUpdate(p);// now database have c1(list_index 0),c2(list_index1),c3(list_index2),c4(list_index3) all get saved and looks fine.
p.getChildren.remove(c3);
pDAO.saveAndUpdate(p);// now c3 get removed. database have c1(list_index 0),c2(list_index1), c4(list_index3). Here we get a gap.
Child c5 = new Child();
p.getChildren().add(c5);
pDAO.saveAndUpdate(p);// now database have c1(list_index 0),c2(list_index1), c4(list_index3), c5(list_index3). Here we get a gap and a duplicate.
>From this point. the dao can't do anything with p anymore and the data get cruptted.
When do find by id c5 is missing.
I think this is a quite common case that something hibernate should be able to handle and it shouldn't leave gap and generate duplicate list_index.
Is there anyway to fix it in Hibernate?
Thank you very much.
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-4007) Hibernate may generate duplicate/gap list index when cascade save
by LC (JIRA)
Hibernate may generate duplicate/gap list index when cascade save
-----------------------------------------------------------------
Key: HHH-4007
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4007
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.2
Environment: Windows. Java 1.5.14. Spring 2.5.6, Junit 3.8.1. Sybase
Reporter: LC
Say we have ParentTable(p_id, etc) ChildTable(c_id, p_id, listindex)
Parent{
id
Arraylist children;
... properties
}
Child{
id
properties
}
mapping:
Parent.hbm.xml
<class name="Parent" table="ParentTable">
<id name="id" type="java.lang.Long">
<column name="p_id" />
<generator class="native" />
</id>
<list name="children" cascade="all-delete-orphan">
<key column="p_id" not-null="true" update="false"/>
<list-index>
<column name="list_index"/>
</list-index>
<one-to-many class="Child"/>
</list>
</class>
Child.hbm.xml
<class name="Child" table="ChildTable">
<id name="id" type="java.lang.Long">
<column name="c_id"/>
<generator class="native"/>
</id>
</class>
DAO
PDAO extends HibernateDaoSupport{
......
public void saveAndUpdate(Parent instance){
getHibernateTemplate().saveOrUpdate(instance);
}
......
}
Test case:
Parent p = new Parent();
p.setChildren(new Arraylist());
Child c1 = new Child();
Child c2 = new Child();
Child c3 = new Child();
Child c4 = new Child();
p.getChildren().add(c1);
p.getChildren().add(c2);
p.getChildren().add(c3);
p.getChildren().add(c4);
pDAO.saveAndUpdate(p);// now database have c1(list_index 0),c2(list_index1),c3(list_index2),c4(list_index3) all get saved and looks fine.
p.getChildren.remove(c3);
pDAO.saveAndUpdate(p);// now c3 get removed. database have 1(list_index 0),c2(list_index1), c4(list_index3). Here we get a gap.
Child c5 = new Child();
p.getChildren().add(c5);
pDAO.saveAndUpdate(p);// now database have 1(list_index 0),c2(list_index1), c4(list_index3), c5(list_index3). Here we get a gap and a duplicate.
>From this point. the dao can't do anything with the parent anymore and the data get cruptted.
I think this is a quite common case that something hibernate should be able to handle and it shouldn't leave gap and generate duplicate list_index.
Is there anyway to fix it in Hibernate?
Thank you very much.
--
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, 6 months
[Hibernate-JIRA] Created: (HSEARCH-384) improve error messages for loading plugins and add consistency to the performed checks
by Sanne Grinovero (JIRA)
improve error messages for loading plugins and add consistency to the performed checks
--------------------------------------------------------------------------------------
Key: HSEARCH-384
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-384
Project: Hibernate Search
Issue Type: Improvement
Reporter: Sanne Grinovero
Assignee: Sanne Grinovero
Fix For: 3.2.0
the code of Hibernate Search is very extensible, as nearly all
internal modules are "overridable" by user provided implementation;
this external classes are loaded by defining a short name (in case of
built-in extensions) or fully qualified names to load
whatever is on the classpath to replace internals.
For some issues I'll soon have to be copy-pasting the usual exception
handling code around, again..
A quick regex count on the code base reveals that this same code is
duplicated in other 25 places, mostly correct but sometimes
forgetting to handle one or two cases (for example ClassCastException
is not handled often)
I am building a util class to get some consistency, and plan to unit
test this extensively to make sure it throws understandable exceptions
for the most common mistakes (hey, I need a public no-args
constructor! / not implementing the X interface! / ...)
-> DRY, improve error messages.
--
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, 6 months