~ubuntu-branches/ubuntu/wily/libhibernate3-java/wily-proposed

« back to all changes in this revision

Viewing changes to src/org/hibernate/persister/collection/ElementPropertyMapping.java

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-10-14 14:43:34 UTC
  • Revision ID: james.westby@ubuntu.com-20071014144334-eamc8i0q10gs1aro
Tags: upstream-3.2.5
ImportĀ upstreamĀ versionĀ 3.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//$Id: ElementPropertyMapping.java 6179 2005-03-23 15:41:48Z steveebersole $
 
2
package org.hibernate.persister.collection;
 
3
 
 
4
import org.hibernate.MappingException;
 
5
 
 
6
import org.hibernate.QueryException;
 
7
 
 
8
import org.hibernate.persister.entity.PropertyMapping;
 
9
 
 
10
import org.hibernate.type.Type;
 
11
 
 
12
import org.hibernate.util.StringHelper;
 
13
 
 
14
/**
 
15
 * @author Gavin King
 
16
 */
 
17
public class ElementPropertyMapping implements PropertyMapping {
 
18
 
 
19
        private final String[] elementColumns;
 
20
        private final Type type;
 
21
 
 
22
        public ElementPropertyMapping(String[] elementColumns, Type type)
 
23
        throws MappingException {
 
24
                this.elementColumns = elementColumns;
 
25
                this.type = type;
 
26
        }
 
27
 
 
28
        public Type toType(String propertyName) throws QueryException {
 
29
                if ( propertyName==null || "id".equals(propertyName) ) {
 
30
                        return type;
 
31
                }
 
32
                else {
 
33
                        throw new QueryException("cannot dereference scalar collection element: " + propertyName);
 
34
                }
 
35
        }
 
36
 
 
37
        public String[] toColumns(String alias, String propertyName) throws QueryException {
 
38
                if (propertyName==null || "id".equals(propertyName) ) {
 
39
                        return StringHelper.qualify(alias, elementColumns);
 
40
                }
 
41
                else {
 
42
                        throw new QueryException("cannot dereference scalar collection element: " + propertyName);
 
43
                }
 
44
        }
 
45
 
 
46
        /**
 
47
         * Given a property path, return the corresponding column name(s).
 
48
         */
 
49
        public String[] toColumns(String propertyName) throws QueryException, UnsupportedOperationException {
 
50
                throw new UnsupportedOperationException( "References to collections must be define a SQL alias" );
 
51
        }
 
52
 
 
53
        public Type getType() {
 
54
                return type;
 
55
        }
 
56
 
 
57
}
 
 
b'\\ No newline at end of file'