[Hibernate-JIRA] Commented: (HHH-1338) Many to many fails when using mapped column with same name than other column (from other side - entity).
by Airbus Deutschland (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1338?page=c... ]
Airbus Deutschland commented on HHH-1338:
-----------------------------------------
The same problem occurs with xml definition-files.
> Many to many fails when using mapped column with same name than other column (from other side - entity).
> --------------------------------------------------------------------------------------------------------
>
> Key: HHH-1338
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1338
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1
> Environment: Hibernate 3.1
> Dialect: Oracle
> Hibernate Annottations: 3.1 b7
> Reporter: Marcio Wesley Borges
> Attachments: Hibernate.tar.gz
>
>
> The bug that I will be describing occurs when using many-to-many mapping with entities that have at least one column with same name.
> Consider the following tables:
> create table table_A (
> col1 char(10) not null,
> col2 char(10) not null,
> something varchar(30) not null,
> constraint pkA primary key (col1, col2)
> );
> create table table_B (
> column1 char(10) not null,
> col2 char(10) not null,
> column3 char(10) not null,
> something varchar(30) not null,
> constraint pkB primary key (column1, col2, column3)
> );
> create table rel_AB (
> col1 char(10) not null,
> col2 char(10) not null,
> column1 char(10) not null,
> column3 char(10) not null,
> constraint pkRelAB primary key (col1, col2, column1, column3),
> constraint fkRelAB_A foreign key (col1, col2) references table_A(col1, col2),
> constraint fkRelAB_B foreign key (column1, col2, column3) references table_B(column1, col2, column3)
> );
> Also consider the following two java classes EntA and EntB:
> /*
> * EntA.java
> */
> package org.hibernate.bugs.manytomany.b1;
> import java.io.Serializable;
> import javax.persistence.*;
> import java.util.Set;
> @Entity(access=AccessType.PROPERTY)
> @Table(name="table_A")
> @IdClass(EntA.IdA.class)
> public class EntA implements Serializable {
>
> private String col1;
> private String col2;
> private String something;
>
> private Set<EntB> bs;
>
> public EntA() {
> }
>
> public EntA(String col1, String col2, String something) {
> this.col1 = col1;
> this.col2 = col2;
> this.something = something;
> }
>
> //Start duplication of: EntA.IdA
> @Column(name="col1", nullable=false)
> public String getCol1() {
> return col1;
> }
> public void setCol1(String col1) {
> this.col1 = col1;
> }
> @Column(name="col2", nullable=false)
> public String getCol2() {
> return col2;
> }
> public void setCol2(String col2) {
> this.col2 = col2;
> }
> public boolean equals(Object o) {
> if (this==o)
> return true;
>
> if (! (o instanceof IdA) )
> return false;
>
> final IdA id = (IdA)o;
> boolean equals;
>
> equals = (getCol1()!=null) && (getCol1().equals(id.getCol1())) &&
> (getCol2()!=null) && (getCol2().equals(id.getCol2()));
> return equals;
> }
>
> public int hashCode() {
> int h1 = getCol1()==null ? 0 : getCol1().hashCode();
> int h2 = getCol2()==null ? 0 : getCol2().hashCode();
> int h = h1 + h2 * 29;
> return h;
> }
>
> public String toString() {
> return getCol1() + ':' + getCol2();
> }
> //End duplication of: EntA.IdA
>
> @Column(name="something", nullable=false)
> public String getSomething() {
> return something;
> }
> public void setSomething(String something) {
> this.something = something;
> }
> @ManyToMany(
> targetEntity=EntB.class,
> cascade=CascadeType.ALL
> )
> @JoinTable(
> table=@Table(name="rel_AB"),
> joinColumns={
> @JoinColumn(name="col1", referencedColumnName="col1"),
> @JoinColumn(name="col2", referencedColumnName="col2") //<-- see here this column
> },
> inverseJoinColumns={
> @JoinColumn(name="column1", referencedColumnName="column1"),
> @JoinColumn(name="col2", referencedColumnName="col2"), //<-- now the same column here, but to link the other side
> @JoinColumn(name="column3", referencedColumnName="column3")
> }
> )
> @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN } )
> public Set<EntB> getBs() {
> return bs;
> }
> public void setBs(Set<EntB> bs) {
> this.bs = bs;
> }
>
> @Embeddable(access = AccessType.PROPERTY)
> public static class IdA implements Serializable {
> private String col1;
> private String col2;
> public IdA() {}
>
> public IdA(String col1, String col2) {
> this.col1 = col1;
> this.col2 = col2;
> }
> @Column(name="col1", nullable=false)
> public String getCol1() {
> return col1;
> }
> public void setCol1(String col1) {
> this.col1 = col1;
> }
> @Column(name="col2", nullable=false)
> public String getCol2() {
> return col2;
> }
> public void setCol2(String col2) {
> this.col2 = col2;
> }
> public boolean equals(Object o) {
> if (this==o)
> return true;
>
> if (! (o instanceof IdA) )
> return false;
>
> final IdA id = (IdA)o;
> boolean equals;
>
> equals = (getCol1()!=null) && (getCol1().equals(id.getCol1())) &&
> (getCol2()!=null) && (getCol2().equals(id.getCol2()));
> return equals;
> }
>
> public int hashCode() {
> int h1 = getCol1()==null ? 0 : getCol1().hashCode();
> int h2 = getCol2()==null ? 0 : getCol2().hashCode();
> int h = h1 + h2 * 29;
> return h;
> }
>
> public String toString() {
> return getCol1() + ':' + getCol2();
> }
> }
>
> }
> /*
> * EntB.java
> */
> package org.hibernate.bugs.manytomany.b1;
> import java.io.Serializable;
> import javax.persistence.*;
> import java.util.Set;
> @Entity(access=AccessType.PROPERTY)
> @Table(name="table_B")
> @IdClass(EntB.IdB.class)
> public class EntB implements Serializable {
>
> private String column1;
> private String col2;
> private String column3;
> private String something;
>
> private Set<EntA> as;
>
> /**
> * Creates a new instance of EntB
> */
> public EntB() {
> }
>
> public EntB(String column1, String col2, String column3, String something) {
> this.column1 = column1;
> this.col2 = col2;
> this.column3 = column3;
> this.something = something;
> }
>
> //Start duplication of: EntB.IdB
> @Column(name="column1", nullable=false)
> public String getColumn1() {
> return column1;
> }
> public void setColumn1(String column1) {
> this.column1 = column1;
> }
> @Column(name="col2", nullable=false)
> public String getCol2() {
> return col2;
> }
> public void setCol2(String col2) {
> this.col2 = col2;
> }
> @Column(name="column3", nullable=false)
> public String getColumn3() {
> return column3;
> }
> public void setColumn3(String column3) {
> this.column3 = column3;
> }
> public boolean equals(Object o) {
> if (this==o)
> return true;
>
> if (! (o instanceof IdB) )
> return false;
>
> final IdB id = (IdB)o;
> boolean equals;
>
> equals = (getColumn1()!=null) && (getColumn1().equals(id.getColumn1())) &&
> (getCol2()!=null) && (getCol2().equals(id.getCol2())) &&
> (getColumn3()!=null) && (getColumn3().equals(id.getColumn3()));
> return equals;
> }
>
> public int hashCode() {
> int h1 = getColumn1()==null ? 0 : getColumn1().hashCode();
> int h2 = getCol2()==null ? 0 : getCol2().hashCode();
> int h3 = getColumn3()==null ? 0 : getColumn3().hashCode();
> int h = h1 + h2 * 29 + h3 * 43;
> return h;
> }
>
> public String toString() {
> return getColumn1() + ':' + getCol2() + ':' + getColumn3();
> }
> //End duplication of: EntB.IdB
>
> @Column(name="something", nullable=false)
> public String getSomething() {
> return something;
> }
> public void setSomething(String something) {
> this.something = something;
> }
> @ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE},
> mappedBy="bs",
> targetEntity=EntA.class,
> fetch=FetchType.LAZY)
> @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.ALL } )
> public Set<EntA> getAs() {
> return as;
> }
> public void setAs(Set<EntA> as) {
> this.as = as;
> }
>
> @Embeddable(access = AccessType.PROPERTY)
> public static class IdB implements Serializable {
> private String column1;
> private String col2;
> private String column3;
> public IdB() {}
>
> public IdB(String column1, String col2, String column3) {
> this.column1 = column1;
> this.col2 = col2;
> this.column3 = column3;
> }
> @Column(name="column1", nullable=false)
> public String getColumn1() {
> return column1;
> }
> public void setColumn1(String column1) {
> this.column1 = column1;
> }
> @Column(name="col2", nullable=false)
> public String getCol2() {
> return col2;
> }
> public void setCol2(String col2) {
> this.col2 = col2;
> }
> @Column(name="column3", nullable=false)
> public String getColumn3() {
> return column3;
> }
> public void setColumn3(String column3) {
> this.column3 = column3;
> }
> public boolean equals(Object o) {
> if (this==o)
> return true;
>
> if (! (o instanceof IdB) )
> return false;
>
> final IdB id = (IdB)o;
> boolean equals;
>
> equals = (getColumn1()!=null) && (getColumn1().equals(id.getColumn1())) &&
> (getCol2()!=null) && (getCol2().equals(id.getCol2())) &&
> (getColumn3()!=null) && (getColumn3().equals(id.getColumn3()));
> return equals;
> }
>
> public int hashCode() {
> int h1 = getColumn1()==null ? 0 : getColumn1().hashCode();
> int h2 = getCol2()==null ? 0 : getCol2().hashCode();
> int h3 = getColumn3()==null ? 0 : getColumn3().hashCode();
> int h = h1 + h2 * 29 + h3 * 43;
> return h;
> }
>
> public String toString() {
> return getColumn1() + ':' + getCol2() + ':' + getColumn3();
> }
> }
>
> }
> The error occurs while the Hibernate is mapping and it raises:
> Exception in thread "main" org.hibernate.MappingException: Repeated column in mapping for collection: org.hibernate.bugs.manytomany.b1.EntB.as column: col2
> at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:290)
> at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:313)
> at org.hibernate.mapping.Collection.validate(Collection.java:270)
> at org.hibernate.mapping.Set.validate(Set.java:19)
> at org.hibernate.cfg.Configuration.validate(Configuration.java:987)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1147)
> at ...
--
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
18 years
[Hibernate-JIRA] Created: (HBX-841) "Socket closed" exception
by Igor Azevedo Alves (JIRA)
"Socket closed" exception
-------------------------
Key: HBX-841
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-841
Project: Hibernate Tools
Type: Bug
Components: reverse-engineer
Versions: 3.1beta2
Reporter: Igor Azevedo Alves
Priority: Minor
At the end of a an Artifact Generation I see in the log file:
!ENTRY org.hibernate.eclipse 2 30000 2005-10-31 12:26:13.468
!MESSAGE WARN Finalizer org.hibernate.connection.DriverManagerConnectionProvider - problem closing pooled connection
!STACK 0
java.sql.SQLException: Io exception: Socket closed
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
at oracle.jdbc.driver.OracleConnection.close(OracleConnection.java:1478)
at org.hibernate.connection.DriverManagerConnectionProvider.close(DriverManagerConnectionProvider.java:152)
at org.hibernate.connection.DriverManagerConnectionProvider.finalize(DriverManagerConnectionProvider.java:142)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
--
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
18 years
[Hibernate-JIRA] Commented: (HHH-1) Optimize Hibernate for the bulk insertion of related entities
by Martin Ross (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1?page=comm... ]
Martin Ross commented on HHH-1:
-------------------------------
We have something that works (for our moderately) complex object. I will submit patch files against the 3.2 branch. We are seeing real world increases of several hundred percent performance on our system. Please test and give feedback.
Since hibernate batching occurs using PreparedStatement it appears that you need to do a few things to get the MySQL driver to actual even use batching.
A) Use the 5.0.4 connector. The later versions of the 3.1.x series might work.
B) Set useServerPrepStmts=false . MySQL server side prepared statements can't batch yet.
C) Set rewriteBatchedStatements=true . This is the import part.
Also we have discovered some bugs with MySQL and batch inserts.
I have filed two issues on MySQL bugs site http://bugs.mysql.com/bug.php?id=25025 and http://bugs.mysql.com/bug.php?id=25047 . Until these are fixed you will
A) Need to make sure that hibernate show_sql property is off
B) the "insert (..) values (?,?,....)" insert statements generated by hibernate MUST be uppercased. You may need to hack the driver. Or just hack the MySQL connector
> Optimize Hibernate for the bulk insertion of related entities
> -------------------------------------------------------------
>
> Key: HHH-1
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1
> Project: Hibernate3
> Type: New Feature
> Components: core
> Environment: Hibernate 1.2, MySql 3.1
> Reporter: Bradley Leupen
> Priority: Minor
>
>
> It is currently difficult to batch the creation of persistent entities that maintain associations with other entities.
> Add necessary api to hibernate to support the save or update of a collection of entities. An optimization can be applied in this scenario to group inserts / updates by entity class, or table. This will enable the hibernate engine to utilize batching if available, drastically improving performance over a network.
--
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
18 years
[Hibernate-JIRA] Commented: (ANN-332) Using an @OneToMany/ManyToMany to hbm mapped class causes error.
by Mufaddal (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-332?page=co... ]
Mufaddal commented on ANN-332:
------------------------------
Seeing a similar problem here. Just upgraded to hibernate 3.2.1 GA
I have two classes like such:
@Entity
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Category implements TanEntity, Imageable
{
...
@Id
private String id;
@Version
private Long version = null;
....
....
@CollectionOfElements
@OneToMany(cascade = CascadeType.ALL)
@MapKey(name = "name")
@JoinColumn
@Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private Map<String, CategoryAttribute> attributeValues = new HashMap<String, CategoryAttribute>();
....
....
}
@Entity
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class CategoryAttribute implements TanEntity
{
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
private String id;
@Version
private Long version;
private String name;
@CollectionOfElements
@org.hibernate.annotations.MapKey(columns={@Column(name="productCount")})
@Column(name="productCount", nullable=false, columnDefinition="INTEGER UNSIGNED")
private Map<String, Integer> values = new HashMap<String, Integer>();
....
....
}
Both classes are mapped in the hibernate.cfg.xml file like such:
....
....
<mapping class="com.ac.tan.core.beans.CategoryAttribute"/>
<mapping class="com.ac.tan.core.beans.Category"/>
....
When I deploy my web application, I see the following trace in my tomcat logs:
1534 ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/t] listenerStart [3696] - Exception sending context initialized event to listener instance of class com.ac.tan.web.TanContextListener
org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.ac.tan.core.beans.Category.attributeValues[com.ac.tan.core.beans.CategoryAttribute]
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1016)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:567)
at org.hibernate.cfg.annotations.MapBinder$1.secondPass(MapBinder.java:80)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1127)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
at com.ac.tan.core.TanContext.configHibernate(TanContext.java:403)
at com.ac.tan.core.TanContext.startup(TanContext.java:209)
at com.ac.tan.web.TanWebApplication.startup(TanWebApplication.java:134)
at com.ac.tan.web.TanContextListener.contextInitialized(TanContextListener.java:23)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:910)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:873)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
at org.apache.catalina.startup.Catalina.start(Catalina.java:536)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Any pointers?
> Using an @OneToMany/ManyToMany to hbm mapped class causes error.
> ----------------------------------------------------------------
>
> Key: ANN-332
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-332
> Project: Hibernate Annotations
> Type: Bug
> Components: binder
> Versions: 3.1beta8
> Environment: hibernate 3.1
> hibernate-annotations 3.1-beta8
> Reporter: Chris Rudd
> Attachments: mappings.tar.gz
>
>
> Using an OneToMany/ManyToMany relationship to hbm mapped class from an annotated class causes error. If both classes are mapped the same way (annotated or hbm) this works fine. Also using a ManyToOne or OneToOne relationship works correctly.
> Stack Trace :
> org.hibernate.MappingException: Could not determine type for: mappings.HbmMapped, for columns: [org.hibernate.mapping.Column(elt)]
> at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
> at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
> at org.hibernate.mapping.Collection.validate(Collection.java:262)
> at org.hibernate.cfg.Configuration.validate(Configuration.java:988)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
> at mappings.MappingTest.testOneToMany(MappingTest.java:113)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:536)
> at org.testng.internal.Invoker.invokeMethod(Invoker.java:395)
> at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:672)
> at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:92)
> at org.testng.TestRunner.privateRun(TestRunner.java:624)
> at org.testng.TestRunner.run(TestRunner.java:515)
> at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
> at org.testng.SuiteRunner.run(SuiteRunner.java:147)
> at org.testng.eclipse.runner.RemoteTestNG.run(RemoteTestNG.java:98)
> at org.testng.eclipse.runner.RemoteTestNG.main(RemoteTestNG.java:138)
--
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
18 years
[Hibernate-JIRA] Created: (HHH-2307) Optimize select new query calls like "select new Holder(entity, entity.something) ..." so the parser does not treat them as shallow
by Matt Wheeler (JIRA)
Optimize select new query calls like "select new Holder(entity, entity.something) ..." so the parser does not treat them as shallow
-----------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2307
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2307
Project: Hibernate3
Type: New Feature
Components: query-hql
Versions: 3.2.0.ga
Environment: Hibernate Version: 3.2.0ga
Database platform: Oracle 9.2, HSQLDB 1.7.3.3, and Derby 10.2.1.6
Reporter: Matt Wheeler
Priority: Minor
Using the JPA implementation, and the following named query:
@NamedQuery(name=Country.COUNTRIES_AS_SELECT_ITEMS,
query="select new javax.faces.model.SelectItem(c, c.name) from Country c")
Which is called from the following method:
public List<SelectItem> getAllCountriesAsSelectItems() {
return entityManager.createNamedQuery(Country.COUNTRIES_AS_SELECT_ITEMS).getResultList();
}
the following SQL is generated:
Hibernate: select country0_.id as col_0_0_, country0_.name as col_1_0_ from Country country0_
Hibernate: select country0_.id as id3_0_, country0_.name as name3_0_ from Country country0_ where country0_.id=?
Hibernate: select country0_.id as id3_0_, country0_.name as name3_0_ from Country country0_ where country0_.id=?
Hibernate: select country0_.id as id3_0_, country0_.name as name3_0_ from Country country0_ where country0_.id=?
Hibernate: select country0_.id as id3_0_, country0_.name as name3_0_ from Country country0_ where country0_.id=?
Hibernate: select country0_.id as id3_0_, country0_.name as name3_0_ from Country country0_ where country0_.id=?
Assuming that we have 5 countries in the database, calling the method above would result in 6 queries. The first query appears to get all of the ids, and the next 5 queries appear to retrieve the objects by id.
However, if we change the query to:
"select new javax.faces.model.SelectItem(c.name) from Country c" and only select an attribute of country, instead of an attribute of the country and the country entity as well, it will only issue 1 query
I was just wondering if this could be optimized so that there are not n+1 queries in the new Holder(entity, enity.a) instance
Just for reference: As per issue HHH-544 Select new n+1 queries, Gavin responded that the parser treats all select new calls as shallow, as is manifest in the above example.
--
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
18 years