[Hibernate-JIRA] Created: (HHH-3347) Property Injection dos not work for unwanted properties and throw Invalid Coulumn Name Exception
by mahdi asgari (JIRA)
Property Injection dos not work for unwanted properties and throw Invalid Coulumn Name Exception
------------------------------------------------------------------------------------------------
Key: HHH-3347
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3347
Project: Hibernate3
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.5
Reporter: mahdi asgari
To speed up my query i dosn't return unwanted properties from my database function, but hibernate property binder try to set all properties.
I have got the following Exception when running named query "TblBisYeganChildsByYeganId"
I search in the forum and read the hibernate references but i cant find the correct solution,
would you please help me, is it a bug?
I am using Oracle10G,Hibernate 3.2.5.ga
The exception:
Hibernate:
{ ? = call pkg_bis_yegan.func_sel_childsbyyeganid(?) }
[INFO ] - could not read column value from result set: IS6_32_0_; Invalid column name
[WARN ] - SQL Error: 17006, SQLState: null
[ERROR] - Invalid column name
my Hibernate-Mapping xml
<hibernate-mapping>
<class lazy="true" name="com.test.TblBisYegan" table="TBL_BIS_YEGAN" schema="AMAD">
<id name="pkYeganId" type="java.lang.Long">
<column name="PK_YEGAN_ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<many-to-one name="tblBisInfoBaseDetail" class="com.test.TblBisInfoBaseDetail" fetch="join" lazy="false">
<column name="FK_INFO_BASE_DETAIL_ID" precision="22" scale="0" />
</many-to-one>
<many-to-one name="tblBisYegan" class="com.test.TblBisYegan" fetch="join" lazy="false">
<column name="FK_YEGAN_ID" precision="10" scale="0" />
</many-to-one>
<property name="unitNum" type="java.lang.Long">
<column name="UNIT_NUM" precision="22" scale="0" />
</property>
<property name="yeganName" type="java.lang.String">
<column name="YEGAN_NAME" length="100" not-null="true" />
</property>
<property name="isActive" type="java.lang.Long">
<column name="IS_ACTIVE" precision="1" scale="0" />
</property>
<property name="isCreateAmval" type="java.lang.Long">
<column name="IS_CREATE_AMVAL" precision="22" scale="0" />
</property>
</class>
<sql-query name="TblBisYeganChildsByYeganId" callable="true">
<return class="com.test.TblBisYegan">
<return-property name="pkYeganId" column="PK_YEGAN_ID"/>
<return-property name="yeganName" column="YEGAN_NAME"/>
<return-property name="unitNum" column="UNIT_NUM"/>
<return-property name="tblBisInfoBaseDetail">
<return-column name="PK_INFO_BASE_DETAIL_ID"/>
</return-property>
<return-property name="tblBisYegan">
<return-column name="PARENT_YEGAN_ID"/>
</return-property>
</return>
{ ? = call pkg_bis_yegan.func_sel_childsbyyeganid(:pkyeganid) }
</sql-query>
</hibernate-mapping>
My Function is:
create or replace package body pkg_bis_yegan is
function func_sel_childsbyyeganid(p_fk_yegan_id number)
return sys_refcursor is
func_result SYS_REFCURSOR;
begin
open func_result for
select tbl_bis_yegan.pk_yegan_id,
tbl_bis_yegan.yegan_name,
tbl_bis_yegan.unit_num,
null parent_yegan_id, -- if dos not exist hibernate throw exception
null pk_info_base_detail_id -- if dos not exist hibernate throw exception
from tbl_bis_yegan
where tbl_bis_yegan.fk_yegan_id = p_fk_yegan_id
order by tbl_bis_yegan.yegan_name;
return func_result;
end;
end pkg_bis_yegan;
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-3346) New id generator - produce fixed-width string representation of short, int, or long
by Richard Freedman (JIRA)
New id generator - produce fixed-width string representation of short, int, or long
-----------------------------------------------------------------------------------
Key: HHH-3346
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3346
Project: Hibernate3
Issue Type: New Feature
Components: core
Affects Versions: 3.3.0.CR1
Environment: Hibernate 3.x, database agnostic
Reporter: Richard Freedman
Priority: Minor
Attachments: FixedWidthStringIdGenerator.diff
Provide a new id generator that works like IncrementGenerator, but generates fixed-width String representations of short, int, or long values.
For brevity of key, base-36 encode the value via toString(long i, int radix), yielding digits in range '0' - 'z'
Diff is 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, 4 months
[Hibernate-JIRA] Created: (HHH-2357) Patch to work around setDecimal() bug with Oracle JDBC driver < 10.2.0.4 and JDK >= 1.5 (bug 5527479
by Benoit Goudreault-Emond (JIRA)
Patch to work around setDecimal() bug with Oracle JDBC driver < 10.2.0.4 and JDK >= 1.5 (bug 5527479
----------------------------------------------------------------------------------------------------
Key: HHH-2357
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2357
Project: Hibernate3
Type: Patch
Components: core
Versions: 3.2.1
Environment: Hibernate 3.2.1, Oracle 9i, Oracle 10g, JDK 1.5+
Reporter: Benoit Goudreault-Emond
Attachments: WorkaroundForOracleBrokenSetDecimal.patch
First, see http://www.javalobby.org/java/forums/t88158.html
In a nutshell, JDK 1.5 changed the representation of BigDecimal; namely, they changed totally the way toString() works. Nobody is sure how Oracle parses out the BigDecimal for storage inside the database, but it seems BigDecimals with negative scales don't work well. It's not really this surprising, given that Sun did something a bit evil here (changing the contract of the scale property, for one).
The proposed workarounds from Oracle: 1) stay with JDK 1.4 (not an option when you've written several thousand lines of generic-aware code, retroweaver nonwithstanding) 2) wait for their patched JDBC driver.
However, they won't issue a patch for Oracle 9i, and those using the OCI driver are kinda stuck. Plus, Oracle's patch isn't there yet.
This patch is not necessarily meant to go in the main Hibernate code; it is, after all, Oracle's bug. Still, the patch itself is harmless even for other databases (it simply rescales the BigDecimal), and if it's useful to someone, great. It seems to
be a good solution in the meantime.
I've marked this bug as MAJOR because it can lead to data corruption--the BigDecimal put in is not the one you get back.
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-3342) one to many association with a subclass of a class having discriminator column creates wrong sql
by Abhijit (JIRA)
one to many association with a subclass of a class having discriminator column creates wrong sql
------------------------------------------------------------------------------------------------
Key: HHH-3342
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3342
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6, 3.1.3, 3.0.5
Environment: Tested on Hibernate Version 3.0.5, 3.1.1 & 3.2.6.ga. CGLIB-2.1.3
Reporter: Abhijit
I have one abstract class which has two sub classes and each each sub class has further subclasses. The second level subclasses doesn't have tables and only has discriminator value. As below:
<hibernate-mapping
>
<class
name="edu.wustl.catissuecore.domain.AbstractSpecimen"
table="CATISSUE_ABSTRACT_SPECIMEN"
lazy="true"
>
<id
name="id"
column="IDENTIFIER"
type="long"
length="30"
unsaved-value="null"
>
<generator class="native">
<param name="sequence">CATISSUE_ABSTRACT_SPECIMEN_SEQ</param>
</generator>
</id>
<discriminator column="SPECIMEN_CLASS" type="string"/>
<subclass name="edu.wustl.catissuecore.domain.Specimen" discriminator-value="Specimen">
<join table="CATISSUE_SPECIMEN">
<key column="IDENTIFIER"/>
<property
name="positionDimensionOne"
type="int"
update="true"
/>
......
</join>
<subclass
name="edu.wustl.catissuecore.domain.FluidSpecimen"
discriminator-value="Fluid" lazy="true"
>
</subclass>
<subclass name="edu.wustl.catissuecore.domain.CellSpecimen"
discriminator-value="Cell" lazy="true"
>
</subclass>
</subclass>
<subclass name="edu.wustl.catissuecore.domain.RequirementSpecimen" discriminator-value="ReqSpecimen">
<join table="CATISSUE_CP_REQ_SPECIMEN">
<key column="IDENTIFIER"/>
<property
name="storageType"
type="int"
update="true"
/>
......
</join>
<subclass
name="edu.wustl.catissuecore.domain.FluidSpecimen"
discriminator-value="Fluid" lazy="true"
>
</subclass>
<subclass name="edu.wustl.catissuecore.domain.CellSpecimen"
discriminator-value="Cell" lazy="true"
>
</subclass>
</subclass>
</class>
</hibernate-mapping>
--------------------------------------
<hibernate-mapping
>
<class
name="edu.wustl.catissuecore.domain.AbstractSpecimenCollectionGroup"
table="CATISSUE_ABS_SPECI_COLL_GROUP"
lazy="true"
>
<id
name="id"
column="IDENTIFIER"
type="long"
length="30"
unsaved-value="null"
>
<generator class="native">
<param name="sequence">CATISSUE_SPECIMEN_COLL_GRP_SEQ</param>
</generator>
</id>
<property
name="name"
type="string"
update="true"
insert="true"
column="NAME"
length="255"
/>
<property
name="clinicalDiagnosis"
type="string"
update="true"
insert="true"
column="CLINICAL_DIAGNOSIS"
length="150"
/>
.....
.......
<joined-subclass
name="edu.wustl.catissuecore.domain.CollectionProtocolEvent"
table="CATISSUE_COLL_PROT_EVENT" lazy="false"
>
<key
column="IDENTIFIER"
/>
<property
name="collectionPointLabel"
type="string"
update="true"
insert="true"
column="COLLECTION_POINT_LABEL"
length="255"
/>
<set
name="requirementSpecimenCollection"
table="CATISSUE_CP_REQ_SPECIMEN"
lazy="true"
inverse="true"
cascade="save-update"
fetch="subselect"
sort="unsorted"
>
<key
column="COLLECTION_PROTOCOL_EVENT_ID"
/>
<one-to-many
class="edu.wustl.catissuecore.domain.RequirementSpecimen"
/>
</set>
.....
</joined-subclass>
</class>
</hibernate-mapping>
--------------------------------------
In above configuration 'CollectionProtocolEvent' which is a joined -subclass of 'AbstractSpecimenCollectionGroup' has one to many association with RequirementSpecimen which is subclass of AbstractSpecimen.
It was found that whenever we execute following code:
line 1: CollectionProtocolEvent cpe =(CollectionProtocolEvent) session.get(CollectionProtocolEvent.class,new Long(101));
line2: cpe.getRequirementSpecimenCollection ();
At line 2 hibernate generates wrong query. In select column it generates
'AbstractSpecimen.COLLECTION_PROTOCOL_EVENT_ID,...from' but it should be 'RequirementSpecimen .COLLECTION_PROTOCOL_EVENT_ID,...from..'
Hence it gives error "unknown column" It has been observed that inner join part of the query gets generated properly. But in select part it always takes parent table's alias.
In case we use joined-class instead of subclass without driminator everything works fine.
--
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, 4 months
[Hibernate-JIRA] Created: (EJB-266) lazy initialization of one-to-many bidirectional relationships through cascade.persist
by sara forghani (JIRA)
lazy initialization of one-to-many bidirectional relationships through cascade.persist
--------------------------------------------------------------------------------------
Key: EJB-266
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-266
Project: Hibernate Entity Manager
Type: Bug
Components: EntityManager
Versions: 3.2.1
Environment: hibernate 3.2.2, hibernate-entitymanager 3.2.1.ga
Reporter: sara forghani
Priority: Critical
hibernate initializes lazy objects traversed by the persist operation;
for example, in this case (the project is attached):
class A has bidirectional one-to-many relationship to classes B1, B2, B3, B4
(b1List, b2List, b3List, b4List)
B1 has bidirectional one-to-many relationship to C1
(c1List)
B2 has bidirectional one-to-many relationship to C2
(c2List)
if we try persisting C2, it will also initialize B1, C1, B4 ... and other existing C2's
(you may find a more complete description of the issue at http://forum.hibernate.org/viewtopic.php?p=2340004#2340004)
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-2741) Deleting objects on inverse end of many to many relationship
by James Roper (JIRA)
Deleting objects on inverse end of many to many relationship
------------------------------------------------------------
Key: HHH-2741
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2741
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.1
Reporter: James Roper
I have a Class, Stock, that has a bidirectional many to many indexed relationship with itself. Here is the mapping:
@ManyToMany
@JoinTable(name = "input_output_stock", joinColumns = @JoinColumn(name = "id_output_stock"), inverseJoinColumns = @JoinColumn(name = "id_input_stock"))
@IndexColumn(name = "ix_input_stock")
@ForeignKey(name = "stock_output_fk", inverseName = "stock_input_fk")
private List<Stock> inputStock;
@ManyToMany(mappedBy = "inputStock")
private List<Stock> outputStock;
When I delete stock objects, Hibernate runs the following queries:
Hibernate:
delete
from
input_output_stock
where
id_output_stock=?
Hibernate:
delete
from
stock
where
id=?
This causes problems when deleting objects that are at the inverse end of the relationship. Shouldn't Hibernate be running another query to delete where id_input_stock=? As far as I can see in the Hibernate documentation and the EJB3 spec, there is no mention that this is the case.
--
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, 4 months
[Hibernate-JIRA] Commented: (HHH-1574) AbstractEntityPersister.getNaturalIdentifierSnapshot doesn't work with many-to-one ids
by CHRISTIAN BOURQUE (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1574?page=c... ]
CHRISTIAN BOURQUE commented on HHH-1574:
----------------------------------------
I've been struggling with this issue for the past 8 hours thinking the bug was in our code only to find out that it's a Hibernate bug!
And the bug is still "unassigned" after 2 years? Unbelievable!
> AbstractEntityPersister.getNaturalIdentifierSnapshot doesn't work with many-to-one ids
> --------------------------------------------------------------------------------------
>
> Key: HHH-1574
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1574
> Project: Hibernate3
> Issue Type: Patch
> Affects Versions: 3.1.2
> Reporter: Alex Burgel
> Attachments: resolveentity.patch, resolveentity32.patch, testcase.zip
>
>
> i just upgraded from 3.0.5 to 3.1.2, and i started seeing this problem. i'm not exactly sure where the bug is here, but this is what i'm seeing:
> i have a class, Subscription, which has a natural-id of class Subscriber and Edition (excerpts of relevant mapping files below).
> when Subscription is unloaded, if i make a change, then commit the session, i see this exception:
> HibernateException: immutable natural identifier of an instance of Subscription was altered
> this gets thrown from DefaultFlushEntityEventListener.checkNaturalId() line 80.
> i traced through that method, this is what happens:
> 1. in checkNaturalId, loaded == null , so getNaturalIdSnapshot() is called
> 2. this ends up generating some sql that selects the SubscriptionId and EditionId from the Subscription row.
> 3. the sql is generated in AbstractEntityPersister.getNaturalIdentifierSnapshot(), which calls hydrate for each returned column of the natural-id,
> 4. but hydrate only returns the id, instead of the actual entity
> 5. so this array of ids (instead of entities) ends up back in DefaultFlushEntityEventListener.checkNaturalId() as 'loaded', which gets compared to 'current'
> the trouble is that 'current' contains the entities, but 'loaded' only contains the ids of those entites, so the natural-id check fails, and i get the exception.
> this only happens when 'loaded' is null in checkNaturalId().
> the javadocs for hydrate say you have to call "resolve" afterwards... this isn't being done, so maybe thats the fix. if the natural-id is not just simple properties, then resolve should also be called.
> <class name="Subscription" table="Subscriptions" batch-size="10">
> <id name="id" column="Id" type="int"><generator class="native" /></id>
> <natural-id>
> <many-to-one name="subscriber" class="Subscriber" column="SubscriberId" />
> <many-to-one name="edition" class="Edition" column="EditionId" />
> </natural-id>
> ....
> </class>
> <class name="Subscriber" table="Subscriber">
> <id name="id" column="id" type="int"><generator class="native" /></id>
> <map name="subscriptions" inverse="true" cascade="all,delete-orphan" batch-size="10">
> <key column="SubscriberId" />
> <map-key-many-to-many column="EditionId" class="Edition" />
> <one-to-many class="Subscription" />
> </map>
> </class>
--
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, 4 months
[Hibernate-JIRA] Commented: (HBX-469) Named Query DAO methods with Primitive types fail to compile
by Joe Porcheddu (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-469?page=co... ]
Joe Porcheddu commented on HBX-469:
-----------------------------------
Created HBX-1065 and attached test case.
> Named Query DAO methods with Primitive types fail to compile
> ------------------------------------------------------------
>
> Key: HBX-469
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-469
> Project: Hibernate Tools
> Issue Type: Bug
> Components: hbm2java
> Affects Versions: 3.1beta1
> Reporter: James Schopp
> Fix For: 3.2beta6
>
>
> if you define a name query that receives a primitive or wrapper parameter, then the DAO method for the name query will always be generated with "primitive" type. This failsto compile, since the call to query.setParameter("paramName", value); takes an object, not a primitive. For example:
> <query name="com.mycom.persistence.Account.findCommercialAccountById">
> from Account where accountTypeClass='C' and accountNumber=:accountNumber
> <query-param name="accountNumber" type="java.lang.Long" />
> </query>
> This generates the code
> public List findCommercialAccountById(long accountNumber) {
> Query query = getSession(false)
> .getNamedQuery("com.alldata.ecis.persistence.Account.findCommercialAccountById");
> query.setParameter("accountNumber", accountNumber);
> return query.list();
> }
> This code does not compile.
> I beleive the fix might be as simple as modifying Cfg2JavaTool.asFinderArgumentList():
> if ( type instanceof PrimitiveType ) {
> typeClass = ( (PrimitiveType) type ).getPrimitiveClass();
> }
> else {
> typeClass = type.getReturnedClass();
> }
> I think this should always return the type.getReturnedClass(), and never the primitive...
> ALSO: it would ne nice to have another Cfg2JavaTool function like
> asFinderArgumentList
> but that generates the list as parameters to the call, not the function definition.
> For example, if a named query takes params:
> Long accountNumer, String accountName
> then, maybe have function called
> asFinderCallerArgumentList()
> which would return
> accountNumer, accountName
--
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, 4 months
[Hibernate-JIRA] Commented: (HBX-469) Named Query DAO methods with Primitive types fail to compile
by Max Rydahl Andersen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-469?page=co... ]
Max Rydahl Andersen commented on HBX-469:
-----------------------------------------
this issue was fixed - if you got a testcase for it then please create a new issue and attach it there.
> Named Query DAO methods with Primitive types fail to compile
> ------------------------------------------------------------
>
> Key: HBX-469
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-469
> Project: Hibernate Tools
> Issue Type: Bug
> Components: hbm2java
> Affects Versions: 3.1beta1
> Reporter: James Schopp
> Fix For: 3.2beta6
>
>
> if you define a name query that receives a primitive or wrapper parameter, then the DAO method for the name query will always be generated with "primitive" type. This failsto compile, since the call to query.setParameter("paramName", value); takes an object, not a primitive. For example:
> <query name="com.mycom.persistence.Account.findCommercialAccountById">
> from Account where accountTypeClass='C' and accountNumber=:accountNumber
> <query-param name="accountNumber" type="java.lang.Long" />
> </query>
> This generates the code
> public List findCommercialAccountById(long accountNumber) {
> Query query = getSession(false)
> .getNamedQuery("com.alldata.ecis.persistence.Account.findCommercialAccountById");
> query.setParameter("accountNumber", accountNumber);
> return query.list();
> }
> This code does not compile.
> I beleive the fix might be as simple as modifying Cfg2JavaTool.asFinderArgumentList():
> if ( type instanceof PrimitiveType ) {
> typeClass = ( (PrimitiveType) type ).getPrimitiveClass();
> }
> else {
> typeClass = type.getReturnedClass();
> }
> I think this should always return the type.getReturnedClass(), and never the primitive...
> ALSO: it would ne nice to have another Cfg2JavaTool function like
> asFinderArgumentList
> but that generates the list as parameters to the call, not the function definition.
> For example, if a named query takes params:
> Long accountNumer, String accountName
> then, maybe have function called
> asFinderCallerArgumentList()
> which would return
> accountNumer, accountName
--
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, 4 months