[Hibernate-JIRA] Created: (HHH-4795) Comparing OneToOne mappedBy column to null generates wrong SQL
by Uros Majeric (JIRA)
Comparing OneToOne mappedBy column to null generates wrong SQL
--------------------------------------------------------------
Key: HHH-4795
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4795
Project: Hibernate Core
Issue Type: Bug
Environment: Hibernate core 3.3.2.GA
Postgresql 8.4
Reporter: Uros Majeric
I have two entities:
@Entity
@Table(name = "beer_keg")
public class Keg implements Serializable {
@Id
@GeneratedValue
@Column(name = "bkid")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@OneToOne(mappedBy="keg", fetch=FetchType.LAZY, optional=true)
public KegValveCombination getCombination() {
return combination;
}
void setCombination(KegValveCombination combination) {
this.combination = combination;
}
}
and
@Entity
@Table(name="keg_valve_combination")
public class KegValveCombination implements Serializable {
@Id
@GeneratedValue
@Column(name="id", nullable=false)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="keg", nullable=false, unique=true)
public Keg getKeg() {
return keg;
}
public void setKeg(Keg keg) {
this.keg = keg;
}
}
if I create query:
em.createQuery("FROM Keg k WHERE k.combination is null").getResultList();
hibernate generates sql like:
select keg0_.* from beer_keg keg0_ where keg0_.bkid is null
but it should be:
select keg0_.* from beer_keg keg0_ left join keg_valve_combination kegvalveco1_ on keg0_.bkid=kegvalveco1_.keg where (kegvalveco1_.keg is null)
thanks, Uros
--
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
14 years, 1 month
[Hibernate-JIRA] Created: (HHH-4453) Reserved keywords not quoted in table/column names
by Philipp Reichart (JIRA)
Reserved keywords not quoted in table/column names
--------------------------------------------------
Key: HHH-4453
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4453
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: Hibernate 3.3.1 GA, Windows XP, Sun JDK 1.6.0_06, Derby 10.5
Reporter: Philipp Reichart
I'm currently migrating our test suite form HSQLDB to Derby (we need transaction isolation and the HSLDB 1.9 RCs are no good), and found out that we have a lot of table or colum names that happen to be reserved keywords in Derby, like "transaction", "key", "value", "year", etc..
The usual workaround seems to be adding backticks to any offending table/column name in our hbm.xml files, but that's really an ugly workaround and doesn't prevent later incidents of this kind when new keywords show up in either our mappings or database. As this is about a production database schema, reanming the table/column names isn't an option either.
I already tried implementing a custom Derby dialect and registering all the keywords from the Derby doc at http://db.apache.org/derby/docs/10.5/ref/rrefkeywords29722.html and even defined a "quote everything" NamingStrategy using the dialect to get the correct native quotes for the database.
Unfortunately, neither the Hibernate DDL generator nor HQL queries seem to consider the naming strategy or dialect when handling table or column names.
Is there any way to have Hibernate quote database-specific keywords every they're used?
Or just have Hibernate quote everything that comes from a mapping file?
--
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
14 years, 1 month
[Hibernate-JIRA] Created: (HHH-2097) LAZY property results in org.hibernate.TransientObjectException after merge
by Reto Urfer (JIRA)
LAZY property results in org.hibernate.TransientObjectException after merge
---------------------------------------------------------------------------
Key: HHH-2097
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2097
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.cr4
Environment: Hibernate3.2 cr4 with Annotations cr2 and EntityManager cr2, Oracle10g R2, WindowsXP
Reporter: Reto Urfer
Priority: Critical
Attachments: BugLazyPropertyMerge.zip
Entity1 has a property e2 which references Entity2. This property is defined as follows.
@ManyToOne(fetch = FetchType.LAZY, optional = false)
private Entity2 e2;
If you have an instance e1 of Entity1 which has not initialized property e2 and you merge e1 to the EntityManager within a transaction, then you get the following exception during commit:
Exception in thread "main" javax.persistence.RollbackException: Error while commiting the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:63)
at com.test.Test.main(Test.java:42)
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.test.Entity1.e2 -> com.test.Entity2
at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:350)
at org.hibernate.engine.Cascade.cascade(Cascade.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:130)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:53)
... 1 more
I added a small Testproject to reproduce this bug.
--
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
14 years, 2 months
[Hibernate-JIRA] Created: (HBX-1042) Make DocHelper robust against failing buildSettings()
by Arnout Engelen (JIRA)
Make DocHelper robust against failing buildSettings()
-----------------------------------------------------
Key: HBX-1042
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1042
Project: Hibernate Tools
Issue Type: Improvement
Components: hbm2doc
Reporter: Arnout Engelen
Attachments: dochelper.diff.txt
DocHelper calls cfg.buildSettings(). to get the Dialect, default catalog name and default schema name.
However, cfg.buildSettings() may fail with a HibernateException (example below).
It would be nice to have DocHelper handle this more gracefully. Attached is a simple patch that does this.
(background: I'd like to use the Configuration I'm getting from a Spring LocalSessionFactoryBean, which after initial creation leaves its LocalDataSourceConnectionProvider in a state that yiels a HibernateException when calling 'configure()' on it, which buildSettings() does. Because of this issue, I cannot use the DocExporter for my Spring-based hibernate configurations)
--
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
14 years, 2 months