[Hibernate-JIRA] Created: (HHH-3891) one-to-one with property-ref always non-lazy
by Sandeep Vaid (JIRA)
one-to-one with property-ref always non-lazy
--------------------------------------------
Key: HHH-3891
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3891
Project: Hibernate Core
Issue Type: Bug
Components: core
Reporter: Sandeep Vaid
I have one-to-one relationship betnwee Product and ProductBasic.
<one-to-one name="productBasic" cascade="save-update" property-ref="activeProduct" lazy="proxy">
<formula>'1'</formula>
<formula>PRODUCTID</formula>
</one-to-one>
ProductBasic.hbm.xml as :
<properties name="activeProduct">
<property name="Code" column="CODE"></property>
<property name="pId" column="PID" insert="false" update="false"></property>
</properties>
When i am using property-ref, and try to load Product, it eagerly fetches ProductBasic also as :
select *
from PRODUCT productbo0_ left outer join PRODUCTPERIOD productbas1_ on '18'=productbas1_.CODE and productbo0_.PID=productbas1_.PID where productbo0_.PID=?
NOTE: Along with Product, ProductBasic is also fetched in a single query.
Even if i add constrained="true" in one-to-one mapping, the query gets fired as :
select * from PRODUCT productbo0_ where productbo0_.PID=?
select * from PRODUCTBASIC productbas0_ where productbas0_.CODE=? and productbas0_.PID=?
NOTE: Along with Product, ProductBasic is also fetched in a different query.
BUT in both these cases, ProductBasic is fetched always (non-lazy)..
How can i fetch ProductBasic in a Non-Lazy manner in this 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
15 years, 3 months
[Hibernate-JIRA] Created: (HHH-4119) Duplicate alias
by roger cheng (JIRA)
Duplicate alias
----------------
Key: HHH-4119
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4119
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5, database sybase 12.52
Reporter: roger cheng
Attachments: SybaseIssue.tar.gz
The mapping file I used:
<hibernate-mapping package="com.novell.uddi3.hibernate.entities">
<class name="BusinessVO" table="businessvo">
<id name="id" type="string">
<generator class="assigned" />
</id>
<list name="Contacts" cascade="delete" lazy="true">
<key column="bid" />
<list-index column="sortorder"/>
<one-to-many class="ContactVO" />
</list>
</class>
<class name="ContactVO" table="contacts">
<id name="id">
<generator class="native"/>
</id>
<array name="PersonName" cascade="all" table="personnames" fetch="join">
<key column="cid" />
<list-index column="sortorder"/>
<composite-element class="org.uddi.v3.core.PersonName">
<property name="_value" type="string" column="personname" length="4000"/>
</composite-element>
</array>
</class>
</hibernate-mapping>
When I execute a hsql like following:
Query q = session.createQuery("from BusinessVO b" +
" left join fetch b.Contacts c" +
" left join fetch c.PersonName");
BusinessVO vo = (BusinessVO)q.uniqueResult();
>From the console, the following sql was created:
select
businessvo0_.id as id0_0_,
contacts1_.id as id1_1_,
personname2_.cid as cid1__,
personname2_.personname as personname1__,
personname2_.sortorder as sortorder1__,
contacts1_.bid as bid0__,
contacts1_.id as id0__,
contacts1_.sortorder as sortorder0__,
personname2_.cid as cid1__,
personname2_.personname as personname1__,
personname2_.sortorder as sortorder1__
from
businessvo businessvo0_
left outer join
contacts contacts1_
on businessvo0_.id=contacts1_.bid
left outer join
personnames personname2_
on contacts1_.id=personname2_.cid
The alias 'cid1__, personename1__, sortorder1__' are duplicate, is this a bug of hibernate?
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2988) UnionSubclassEntityPersister.generateSubquery() does not use column.getQuotedName()
by benoit heinrich (JIRA)
UnionSubclassEntityPersister.generateSubquery() does not use column.getQuotedName()
-----------------------------------------------------------------------------------
Key: HHH-2988
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2988
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Reporter: benoit heinrich
Priority: Critical
Hi all,
I'm new to hibernate and I'm trying to use the Inheritance strategy TABLE_PER_CLASS with a Postgres database.
The postgres database contains tables and column with upper cases names (names must be quoted).
In the entity I used the back-quote ` sign to quote the table names and column names.
All basic requests work but when I have an association going to the virtual parent table then I got an error due to the fact that the Union subclass entity persister does not quote the column names inside the sub query.
I've locate the problem and I think it occurs here:
org.hibernate.persister.entity.UnionSubclassEntityPersister.java (svn rev. 11398)
line 395 ------------------------------------------------------------------------------------------------
while ( citer.hasNext() ) {
Column col = (Column) citer.next();
if ( !table.containsColumn(col) ) {
int sqlType = col.getSqlTypeCode(mapping);
buf.append( dialect.getSelectClauseNullString(sqlType) )
.append(" as ");
}
buf.append( col.getName() );
buf.append(", ");
But should be ------------------------------------------------------------------------------------------------
buf.append( col.getQuotedName() );
Here is an example to test:
Item.java:
---------------------------------
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Item implements java.io.Serializable {
private long id;
private Container parent;
/** getter / setter */
@Id
@Column(name = "`ID`", unique = true, nullable = false, insertable = true, updatable = true)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "item_id_seq_generator")
@SequenceGenerator(name="item_id_seq_generator", sequenceName="item_id_seq", allocationSize=1)
public long getId() {
return this.id;
}
public void setId(long id) {
this.id = id;
}
@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "`ParentID`", unique = false, nullable = true, insertable = true, updatable = true)
public Container getParent() {
return this.parent;
}
public void setParent(Container parent) {
this.parent = parent;
}
}
Container.java
---------------------------------
@Entity
@Table(name = "`CoNTaiNeR`")
public class Container extends Item {
private Set<Item> items = new HashSet<Item>(0);
@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "parent", targetEntity = Item.class)
public Set<Item> getItems() {
return this.items;
}
public void setItems(Set<Item> items) {
this.items = items;
}
}
SimpleItem.java
---------------------------------
@Entity
@Table(name = "`SimpleItem`")
public class SimpleItem extends Item {
/*...*/
}
So when you try to get the Container.getItems() then it generates the wrong query.
Cheers,
/Benoit
--
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, 3 months