Source Code Cross Referenced for AbstractType.java in  » Database-ORM » hibernate » org » hibernate » type » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » hibernate » org.hibernate.type 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$Id: AbstractType.java 7793 2005-08-10 05:06:40Z oneovthafew $
002:        package org.hibernate.type;
003:
004:        import java.io.Serializable;
005:        import java.sql.ResultSet;
006:        import java.sql.SQLException;
007:        import java.util.Map;
008:
009:        import org.dom4j.Element;
010:        import org.dom4j.Node;
011:        import org.hibernate.EntityMode;
012:        import org.hibernate.HibernateException;
013:        import org.hibernate.engine.SessionFactoryImplementor;
014:        import org.hibernate.engine.SessionImplementor;
015:        import org.hibernate.util.EqualsHelper;
016:
017:        /**
018:         * Abstract superclass of the built in Type hierarchy.
019:         * @author Gavin King
020:         */
021:        public abstract class AbstractType implements  Type {
022:
023:            public boolean isAssociationType() {
024:                return false;
025:            }
026:
027:            public boolean isCollectionType() {
028:                return false;
029:            }
030:
031:            public boolean isComponentType() {
032:                return false;
033:            }
034:
035:            public boolean isEntityType() {
036:                return false;
037:            }
038:
039:            public boolean isXMLElement() {
040:                return false;
041:            }
042:
043:            public int compare(Object x, Object y, EntityMode entityMode) {
044:                return ((Comparable) x).compareTo(y);
045:            }
046:
047:            public Serializable disassemble(Object value,
048:                    SessionImplementor session, Object owner)
049:                    throws HibernateException {
050:
051:                if (value == null) {
052:                    return null;
053:                } else {
054:                    return (Serializable) deepCopy(value, session
055:                            .getEntityMode(), session.getFactory());
056:                }
057:            }
058:
059:            public Object assemble(Serializable cached,
060:                    SessionImplementor session, Object owner)
061:                    throws HibernateException {
062:                if (cached == null) {
063:                    return null;
064:                } else {
065:                    return deepCopy(cached, session.getEntityMode(), session
066:                            .getFactory());
067:                }
068:            }
069:
070:            public boolean isDirty(Object old, Object current,
071:                    SessionImplementor session) throws HibernateException {
072:                return !isSame(old, current, session.getEntityMode());
073:            }
074:
075:            public Object hydrate(ResultSet rs, String[] names,
076:                    SessionImplementor session, Object owner)
077:                    throws HibernateException, SQLException {
078:                // TODO: this is very suboptimal for some subclasses (namely components),
079:                // since it does not take advantage of two-phase-load
080:                return nullSafeGet(rs, names, session, owner);
081:            }
082:
083:            public Object resolve(Object value, SessionImplementor session,
084:                    Object owner) throws HibernateException {
085:                return value;
086:            }
087:
088:            public Object semiResolve(Object value, SessionImplementor session,
089:                    Object owner) throws HibernateException {
090:                return value;
091:            }
092:
093:            public boolean isAnyType() {
094:                return false;
095:            }
096:
097:            public boolean isModified(Object old, Object current,
098:                    boolean[] checkable, SessionImplementor session)
099:                    throws HibernateException {
100:                return isDirty(old, current, session);
101:            }
102:
103:            public boolean isSame(Object x, Object y, EntityMode entityMode)
104:                    throws HibernateException {
105:                return isEqual(x, y, entityMode);
106:            }
107:
108:            public boolean isEqual(Object x, Object y, EntityMode entityMode) {
109:                return EqualsHelper.equals(x, y);
110:            }
111:
112:            public int getHashCode(Object x, EntityMode entityMode) {
113:                return x.hashCode();
114:            }
115:
116:            public boolean isEqual(Object x, Object y, EntityMode entityMode,
117:                    SessionFactoryImplementor factory) {
118:                return isEqual(x, y, entityMode);
119:            }
120:
121:            public int getHashCode(Object x, EntityMode entityMode,
122:                    SessionFactoryImplementor factory) {
123:                return getHashCode(x, entityMode);
124:            }
125:
126:            protected static void replaceNode(Node container, Element value) {
127:                if (container != value) { //not really necessary, I guess...
128:                    Element parent = container.getParent();
129:                    container.detach();
130:                    value.setName(container.getName());
131:                    value.detach();
132:                    parent.add(value);
133:                }
134:            }
135:
136:            public Type getSemiResolvedType(SessionFactoryImplementor factory) {
137:                return this ;
138:            }
139:
140:            public Object replace(Object original, Object target,
141:                    SessionImplementor session, Object owner, Map copyCache,
142:                    ForeignKeyDirection foreignKeyDirection)
143:                    throws HibernateException {
144:                boolean include;
145:                if (isAssociationType()) {
146:                    AssociationType atype = (AssociationType) this ;
147:                    include = atype.getForeignKeyDirection() == foreignKeyDirection;
148:                } else {
149:                    include = ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT == foreignKeyDirection;
150:                }
151:                return include ? replace(original, target, session, owner,
152:                        copyCache) : target;
153:            }
154:
155:            public void beforeAssemble(Serializable cached,
156:                    SessionImplementor session) {
157:            }
158:
159:            /*public Object copy(Object original, Object target, SessionImplementor session, Object owner, Map copyCache)
160:            throws HibernateException {
161:            	if (original==null) return null;
162:            	return assemble( disassemble(original, session), session, owner );
163:            }*/
164:
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.