Source Code Cross Referenced for DbOrm.java in  » Development » jodd » jodd » db » orm » 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 » Development » jodd » jodd.db.orm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 2003-2007, Jodd Team (jodd.sf.net). All Rights Reserved.
002:
003:        package jodd.db.orm;
004:
005:        import java.util.HashMap;
006:        import java.util.Map;
007:
008:        /**
009:         * Global DB-ORM mapping definitions, prefixes and cache.
010:         * 
011:         * <p>
012:         * Mapping definitions are used <b>only</b> by a result set mapper (such as {@link jodd.db.orm.mapper.ResultSetMapper}
013:         * to lookup for an entity from table name. Table names are read from result-set meta data, for example.
014:         * Moreover, it is not needed to use mappings at all: in that case just provide entity types during result set to
015:         * objects conversion.
016:
017:         */
018:        public class DbOrm {
019:
020:            /**
021:             * Singleton.
022:             */
023:            protected DbOrm() {
024:            }
025:
026:            // ---------------------------------------------------------------- singleton
027:
028:            protected static DbOrm orm = new DbOrm();
029:
030:            /**
031:             * Returns current DB-ORM instance.
032:             */
033:            public static DbOrm getInstance() {
034:                return orm;
035:            }
036:
037:            /**
038:             * Sets new default instance for DB-ORM mapper.
039:             * If parameter is <code>null</code> current instance will be replaced
040:             * with new instance of this class.
041:             */
042:            public static void setInstance(DbOrm orm) {
043:                if (orm == null) {
044:                    orm = new DbOrm();
045:                }
046:                DbOrm.orm = orm;
047:            }
048:
049:            // ---------------------------------------------------------------- prefix
050:
051:            protected String tablePrefix;
052:
053:            /**
054:             * Sets default table prefix for all tables. This prefix affect default
055:             * conversions from bean name to table name and vice-versa when no annotations
056:             * are used.
057:             */
058:            public DbOrm setTablePrefix(String prefix) {
059:                this .tablePrefix = prefix;
060:                return this ;
061:            }
062:
063:            /**
064:             * Returns current table prefix.
065:             */
066:            public String getTablePrefix() {
067:                return tablePrefix;
068:            }
069:
070:            protected String packagePrefix;
071:
072:            /**
073:             * Sets package prefix for all DB entities. Used by {@link jodd.db.orm.sqlgen.DbSqlGenerator}
074:             * during creating sql queries.
075:             */
076:            public DbOrm setPackagePrefix(String prefix) {
077:                if ((packagePrefix != null) && (prefix.endsWith("."))) {
078:                    prefix = prefix.substring(0, prefix.length() - 1);
079:                }
080:                this .packagePrefix = prefix;
081:                return this ;
082:            }
083:
084:            /**
085:             * Returns current package prefix.
086:             */
087:            public String getPackagePrefix() {
088:                return packagePrefix;
089:            }
090:
091:            // ---------------------------------------------------------------- cache
092:
093:            protected Map<Class, DbEntityDescriptor> descriptors = new HashMap<Class, DbEntityDescriptor>();
094:
095:            /**
096:             * Lookups for {@link DbEntityDescriptor}. If it doesn't exist, new one will be created.
097:             * Returns <code>null</code> for core classes from <code>java</code> runtime packages.
098:             */
099:            public DbEntityDescriptor lookup(Class type) {
100:                String typeName = type.getName();
101:                if (typeName.indexOf("java.") == 0) {
102:                    return null;
103:                }
104:                DbEntityDescriptor ded = descriptors.get(type);
105:                if (ded == null) {
106:                    ded = new DbEntityDescriptor(type, this );
107:                    descriptors.put(type, ded);
108:                }
109:                return ded;
110:            }
111:
112:            /**
113:             * Clears descriptors cache.
114:             */
115:            public void clearDescriptorsCache() {
116:                descriptors.clear();
117:            }
118:
119:            // ---------------------------------------------------------------- table separators
120:
121:            protected String columnAliasSeparator = "$";
122:
123:            /**
124:             * Returns value for separator for column aliases that divides table reference and column name.
125:             */
126:            public String getColumnAliasSeparator() {
127:                return columnAliasSeparator;
128:            }
129:
130:            /**
131:             * Specifies separator for column aliases that divides table reference and column name.
132:             * Separator should contains of characters that are not used in table names, such as:
133:             * '$' or '__'.
134:             */
135:            public void setColumnAliasSeparator(String separator) {
136:                this.columnAliasSeparator = separator;
137:            }
138:
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.