Skip to content

Commit c75dafb

Browse files
committed
HHH-7841 - Redesign Loader
1 parent a102bf2 commit c75dafb

11 files changed

+201
-8
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
24+
package org.hibernate.loader.spi;
25+
26+
import java.sql.ResultSet;
27+
import java.sql.SQLException;
28+
import java.util.List;
29+
30+
import org.hibernate.engine.spi.QueryParameters;
31+
import org.hibernate.engine.spi.SessionImplementor;
32+
import org.hibernate.loader.plan.spi.LoadPlan;
33+
import org.hibernate.transform.ResultTransformer;
34+
35+
/**
36+
* Definition of the Loader contract.
37+
* <p/>
38+
* Capabilities I'd like to see added (todo):<ul>
39+
* <li>
40+
* expose the underlying "query" (although what I see here relies heavily on
41+
* https://github.com/hibernate/hibernate-orm/wiki/Proposal---SQL-generation)
42+
* </li>
43+
* </ul>
44+
*
45+
*
46+
* @author Gavin King
47+
* @author Steve Ebersole
48+
*/
49+
public interface Loader {
50+
public LoadPlan getLoadPlan();
51+
52+
/**
53+
* Obtain the on-demand form of this loader, if possible.
54+
*
55+
* @return The on-demand version of this loader
56+
*/
57+
public OnDemandLoader asOnDemandLoader();
58+
59+
public List extractResults(
60+
ResultSet resultSet,
61+
SessionImplementor session,
62+
QueryParameters queryParameters,
63+
boolean returnProxies,
64+
ResultTransformer forcedResultTransformer) throws SQLException;
65+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
24+
package org.hibernate.loader.spi;
25+
26+
import java.sql.ResultSet;
27+
28+
import org.hibernate.HibernateException;
29+
import org.hibernate.engine.spi.QueryParameters;
30+
import org.hibernate.engine.spi.SessionImplementor;
31+
32+
/**
33+
* Represents an on-demand loading strategy as need for processing single *logical* rows one at a time as required
34+
* for {@link org.hibernate.ScrollableResults} implementations.
35+
*
36+
* @author Steve Ebersole
37+
*/
38+
public interface OnDemandLoader {
39+
40+
/**
41+
* Given a ResultSet, extract just a single result row.
42+
*
43+
* Copy of {@link org.hibernate.loader.Loader#loadSingleRow(ResultSet, SessionImplementor, QueryParameters, boolean)}
44+
* but dropping the 'returnProxies' (that method has only one use in the entire codebase and it always passes in
45+
* false...)
46+
*
47+
* @param resultSet The result set being processed.
48+
* @param session The originating session
49+
* @param queryParameters The "parameters" used to build the query
50+
*
51+
* @return The extracted result row
52+
*
53+
* @throws HibernateException Indicates a problem extracting values from the result set.
54+
*/
55+
public Object extractSingleRow(
56+
ResultSet resultSet,
57+
SessionImplementor session,
58+
QueryParameters queryParameters) throws HibernateException;
59+
60+
/**
61+
* Given a ResultSet extract "sequential rows". This is used in cases where we have multi-row fetches that
62+
* are sequential within the ResultSet due to ordering. Multiple ResultSet rows are read into a single query
63+
* result "row".
64+
*
65+
* Copy of {@link org.hibernate.loader.Loader#loadSequentialRowsForward(ResultSet, SessionImplementor, QueryParameters, boolean)}
66+
* but dropping the 'returnProxies' (that method has only one use in the entire codebase and it always passes in
67+
* false...)
68+
*
69+
* @param resultSet The result set being processed.
70+
* @param session The originating session
71+
* @param queryParameters The "parameters" used to build the query
72+
*
73+
* @return The extracted result row
74+
*
75+
* @throws org.hibernate.HibernateException Indicates a problem extracting values from the result set.
76+
*/
77+
public Object extractSequentialRowsForward(
78+
final ResultSet resultSet,
79+
final SessionImplementor session,
80+
final QueryParameters queryParameters) throws HibernateException;
81+
82+
/**
83+
* Like {@link #extractSequentialRowsForward} but here moving back through the ResultSet.
84+
*
85+
* Copy of {@link org.hibernate.loader.Loader#loadSequentialRowsReverse(ResultSet, SessionImplementor, QueryParameters, boolean, boolean)}
86+
* but dropping the 'returnProxies' (that method has only one use in the entire codebase and it always passes in
87+
* false...).
88+
*
89+
* todo : is 'logicallyAfterLastRow really needed? Can't that be deduced? In fact pretty positive it is not needed.
90+
*
91+
* @param resultSet The result set being processed.
92+
* @param session The originating session
93+
* @param queryParameters The "parameters" used to build the query
94+
* @param isLogicallyAfterLast Is the result set currently positioned after the last row; again, is this really needed? How is it any diff
95+
*
96+
* @return The extracted result row
97+
*
98+
* @throws org.hibernate.HibernateException Indicates a problem extracting values from the result set.
99+
*/
100+
public Object extractSequentialRowsReverse(
101+
ResultSet resultSet,
102+
SessionImplementor session,
103+
QueryParameters queryParameters,
104+
boolean isLogicallyAfterLast) throws HibernateException;
105+
}

hibernate-core/src/main/java/org/hibernate/tuple/component/AbstractCompositeBasedAttribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jDocBook, processing of DocBook sources
2+
* Hibernate, Relational Persistence for Idiomatic Java
33
*
44
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
55
* indicated by the @author tags or express copyright attribution

hibernate-core/src/main/java/org/hibernate/tuple/component/AbstractCompositeDefinition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jDocBook, processing of DocBook sources
2+
* Hibernate, Relational Persistence for Idiomatic Java
33
*
44
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
55
* indicated by the @author tags or express copyright attribution

hibernate-core/src/main/java/org/hibernate/tuple/component/CompositeBasedAssociationAttribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jDocBook, processing of DocBook sources
2+
* Hibernate, Relational Persistence for Idiomatic Java
33
*
44
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
55
* indicated by the @author tags or express copyright attribution

hibernate-core/src/main/java/org/hibernate/tuple/component/CompositeBasedBasicAttribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jDocBook, processing of DocBook sources
2+
* Hibernate, Relational Persistence for Idiomatic Java
33
*
44
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
55
* indicated by the @author tags or express copyright attribution

hibernate-core/src/main/java/org/hibernate/tuple/component/CompositeBasedCompositeAttribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jDocBook, processing of DocBook sources
2+
* Hibernate, Relational Persistence for Idiomatic Java
33
*
44
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
55
* indicated by the @author tags or express copyright attribution

hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityBasedAttribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jDocBook, processing of DocBook sources
2+
* Hibernate, Relational Persistence for Idiomatic Java
33
*
44
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
55
* indicated by the @author tags or express copyright attribution

hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityBasedAssociationAttribute.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
124
package org.hibernate.tuple.entity;
225

326
import org.hibernate.engine.FetchStrategy;

hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityBasedBasicAttribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jDocBook, processing of DocBook sources
2+
* Hibernate, Relational Persistence for Idiomatic Java
33
*
44
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
55
* indicated by the @author tags or express copyright attribution

0 commit comments

Comments
 (0)