[Hibernate-JIRA] Created: (HBX-1162) ShemaExport and MappingDiagram aren't working properly with @Embedded annotation
by Dzafar Sadik (JIRA)
ShemaExport and MappingDiagram aren't working properly with @Embedded annotation
--------------------------------------------------------------------------------
Key: HBX-1162
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1162
Project: Hibernate Tools
Issue Type: Bug
Components: annotations (obsolete), visualizations
Affects Versions: 3.2LATER
Environment: Hibernate Core 3.5, MySQLDB
Reporter: Dzafar Sadik
Fields of component that are embedded into some entity are not added to sql ddl statement nor shown on MappingDiagram. However when running an application proper columns are created in the database.
Simple example:
//Definition of component
@Embeddable
@Access(AccessType.FIELD)
public class Address {
protected String street;
protected Integer house;
}
//Definition of class that includes component
import javax.persistence.*;
@Entity (name = "person")
public class Person{
private long id;
private Address address;
public Person(){
}
@Id
@GeneratedValue
public Long getId(){
return id;
}
public void setId(Long id){
this.id = id;
}
@Embedded
public Address getPrimaryAddress(){
return address;
}
public void setPrimaryAddress(Address address){
this.address = address;
}
}
Resulting table includes PRIMARYADDRESS column when running project with ddl auto create. However using SchemaExport from Hibernate Tools thre will be only ID column.
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-3476) Generation of invalid SQL by HQL Delete
by Daniel Nunes (JIRA)
Generation of invalid SQL by HQL Delete
---------------------------------------
Key: HHH-3476
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3476
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.6, 3.1.3
Environment: MS SQL Server 2000, Hibernate 3.1.3 and Hibernate 3.2.6 GA
Reporter: Daniel Nunes
Attachments: grupo.rar, hibernate.cfg.xml
Hibernate generates invalid DML command for HQL Delete statement.
When doing:
Integer vals[] = {1,3};
Query q = ugDAO.createQuery("delete UsuarioGrupo usuariorGrp"+
" where usuariorGrp.usuario.idusuario = :idUsr"+
" and usuariorGrp.grupo.idgrupo in (:idsGrupo)"+
" and usuariorGrp.grupo.cxpostal.idcxpostal = :idCx");
q.setParameterList("idsGrupo", vals);
q.setInteger("idUsr", 77);
q.setInteger("idCx", 2);
It generates an SQL like this:
Hibernate: delete from vanpix.dbo.usuario_grupo, vanpix.dbo.grupo grupo1_ where idusuario=? and (idgrupo in (? , ?)) and idcxpostal=?
17:26:22,406 DEBUG IntegerType:133 - binding '77' to parameter: 1
17:26:22,406 DEBUG IntegerType:133 - binding '1' to parameter: 2
17:26:22,406 DEBUG IntegerType:133 - binding '3' to parameter: 3
17:26:22,406 DEBUG IntegerType:133 - binding '2' to parameter: 4
17:26:22,453 WARN JDBCExceptionReporter:77 - SQL Error: 170, SQLState: 37000
17:26:22,453 ERROR JDBCExceptionReporter:78 - Line 1: Incorrect syntax near ','.
Throwing the exception:
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute update query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:84)
at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:396)
at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:259)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1141)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:94)
at com.pix.tests.HibernateTests.main(HibernateTests.java:37)
Caused by: java.sql.SQLException: Line 1: Incorrect syntax near ','.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2816)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2254)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:631)
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:584)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:546)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:505)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:75)
... 5 more
The HBMs are in the attachment.
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-5118) Criteria not generating whole SQL (missing select, missing join)
by ChB (JIRA)
Criteria not generating whole SQL (missing select, missing join)
----------------------------------------------------------------
Key: HHH-5118
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5118
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.1
Reporter: ChB
Priority: Critical
I use the following code:
class X {
@ManyToMany(mappedBy = "x")
public Set<Y> getY() {
return this.y;
}
}
class Y {
@ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
@JoinTable(name = "x_to_y", joinColumns = { @JoinColumn(name = "y") }, inverseJoinColumns = { @JoinColumn(name = "x") })
public Set<X> getX() {
return this.x;
}
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "y_to_z", joinColumns = { @JoinColumn(name = "y") }, inverseJoinColumns = { @JoinColumn(name = "z") })
@OrderBy("name ASC")
public List<Z> getZ() {
return this.z;
}
}
class Z {
@ManyToMany(mappedBy = "z", cascade = CascadeType.ALL)
public Set<Y> getY() {
return this.y;
}
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "broken")
public Set<Broken> getBroken() {
return this.broken;
}
}
class Broken {
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "z_to_broken", joinColumns = { @JoinColumn(name = "broken") }, inverseJoinColumns = { @JoinColumn(name = "z") })
@OrderBy("name ASC")
public List<Z> getZ() {
return this.z;
}
}
And perform the following criteria query:
Criteria criteria = session.createCriteria(X.class);
Criteria criteriaY = criteria.createCriteria("y");
Criteria criteriaZ = criteriaY.createCriteria("z");
Criteria criteriaBroken = criteriaZ.createCriteria("broken");
criteriaBroken.add(Restrictions.eq("id", 1));
This results in the following SQL
select this_.id as id14_4_,
this_.* as ...,
x_to_y5_.x as x2_14_,
y1_.id as y,
y1_.id as id3_0_,
y1_.* as ...,
z9_.y as y1_3_,
z2_.id as z2_,
z2_.id as id19_3_,
z2_.* as ...,
from y this_
inner join x_to_y x_to_y5_ on this_.id=x_to_y5_.x
left outer join y y1_ on x_to_y5_.y=y1_.id
inner join y_to_z z9_ on y1_.id=z9_.y_id
left outer join z z2_ on z9_.z=z2_.id
inner join z_to_broken broken11_ on z2_.id=broken11_.z
where broken3_.id=1
There are 2 errors in the SQL which might come down to the same issue:
1.) In the select clause right before the 'from y this_' is a ',' which shows that not all columns where put in the select clause.
2.) In the where clause a 'broken3_' is used which was never declared before.
This works fine in Hibernate 3.3.
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-5055) Invalid SQL query generated starting form a Criteria containing two restrictions about class type.
by Alessandro Faraotti (JIRA)
Invalid SQL query generated starting form a Criteria containing two restrictions about class type.
--------------------------------------------------------------------------------------------------
Key: HHH-5055
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5055
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-CR-2
Environment: Hibernate 3.5.0-CR2, Db2 Express C 9.71, Eclipse 3.5, Java 6, Windows
Reporter: Alessandro Faraotti
Attachments: error_details.txt
The hibernate criteria causes an error in DB2
Issue: the SQL query contains 2 parameters, not qualified, both named "clazz_" for the two restictions.
DB2Error: SEVERE: DB2 SQL Error: SQLCODE=-203, SQLSTATE=42702, SQLERRMC=CLAZZ_, DRIVER=3.58.82
Details are 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
14 years, 5 months