01: // $Id: NativeSQLQueryNonScalarReturn.java 7232 2005-06-19 17:16:40 -0500 (Sun, 19 Jun 2005) maxcsaucdk $
02: package org.hibernate.engine.query.sql;
03:
04: import java.io.Serializable;
05: import java.util.Collections;
06: import java.util.HashMap;
07: import java.util.Map;
08:
09: import org.hibernate.HibernateException;
10: import org.hibernate.LockMode;
11:
12: /**
13: * Represents the base information for a non-scalar return defined as part of
14: * a native sql query.
15: *
16: * @author Steve Ebersole
17: */
18: public abstract class NativeSQLQueryNonScalarReturn implements
19: NativeSQLQueryReturn, Serializable {
20: private final String alias;
21: private final LockMode lockMode;
22: private final Map propertyResults = new HashMap();
23:
24: /**
25: * Constructs some form of non-scalar return descriptor
26: *
27: * @param alias The result alias
28: * @param propertyResults Any user-supplied column->property mappings
29: * @param lockMode The lock mode to apply to the return.
30: */
31: protected NativeSQLQueryNonScalarReturn(String alias,
32: Map propertyResults, LockMode lockMode) {
33: this .alias = alias;
34: if (alias == null) {
35: throw new HibernateException("alias must be specified");
36: }
37: this .lockMode = lockMode;
38: if (propertyResults != null) {
39: this .propertyResults.putAll(propertyResults);
40: }
41: }
42:
43: /**
44: * Retrieve the defined result alias
45: *
46: * @return The result alias.
47: */
48: public String getAlias() {
49: return alias;
50: }
51:
52: /**
53: * Retrieve the lock-mode to apply to this return
54: *
55: * @return The lock mode
56: */
57: public LockMode getLockMode() {
58: return lockMode;
59: }
60:
61: /**
62: * Retrieve the user-supplied column->property mappings.
63: *
64: * @return The property mappings.
65: */
66: public Map getPropertyResultsMap() {
67: return Collections.unmodifiableMap(propertyResults);
68: }
69: }
|