Java Doc for DerbyMaxValueIncrementer.java in  » J2EE » spring-framework-2.5 » org » springframework » jdbc » support » incrementer » 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 » J2EE » spring framework 2.5 » org.springframework.jdbc.support.incrementer 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer
      org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer

DerbyMaxValueIncrementer
public class DerbyMaxValueIncrementer extends AbstractDataFieldMaxValueIncrementer (Code)
Class to increment maximum value of a given Derby table with the equivalent of an auto-increment column. Note: If you use this class, your Derby key column should NOT be defined as an IDENTITY column, as the sequence table does the job. Thanks to Endre St¿lsvik for the suggestion!

The sequence is kept in a table. There should be one sequence table per table that needs an auto-generated key.

Derby requires an additional column to be used for the insert since it is impossible to insert a null into the identity column and have the value generated. This is solved by providing the name of a dummy column that also must be created in the sequence table.

Example:

create table tab (id int not null primary key, text varchar(100));
 create table tab_sequence (value int generated always as identity, dummy char(1));
 insert into tab_sequence (dummy) values(null);
If cacheSize is set, the intermediate values are served without querying the database. If the server or your application is stopped or crashes or a transaction is rolled back, the unused values will never be served. The maximum hole size in numbering is consequently the value of cacheSize. HINT: Since Derby supports the JDBC 3.0 method getGeneratedKeys it's recommended to use IDENTITY columns directly in the tables and then utilizing a org.springframework.jdbc.support.KeyHolder when calling the with the update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder) method of the org.springframework.jdbc.core.JdbcTemplate .
author:
   Thomas Risberg
since:
   2.5



Constructor Summary
public  DerbyMaxValueIncrementer()
     Default constructor.
public  DerbyMaxValueIncrementer(DataSource ds, String incrementerName, String columnName)
     Convenience constructor.
public  DerbyMaxValueIncrementer(DataSource ds, String incrementerName, String columnName, String dummyName)
     Convenience constructor.

Method Summary
public  voidafterPropertiesSet()
    
public  intgetCacheSize()
     Return the number of buffered keys.
public  StringgetColumnName()
     Return the name of the column in the sequence table.
public  StringgetDummyName()
     Return the name of the dummy column.
protected synchronized  longgetNextKey()
    
public  voidsetCacheSize(int cacheSize)
     Set the number of buffered keys.
public  voidsetColumnName(String columnName)
     Set the name of the column in the sequence table.
public  voidsetDummyName(String dummyName)
     Set the name of the dummy column.


Constructor Detail
DerbyMaxValueIncrementer
public DerbyMaxValueIncrementer()(Code)
Default constructor.



DerbyMaxValueIncrementer
public DerbyMaxValueIncrementer(DataSource ds, String incrementerName, String columnName)(Code)
Convenience constructor.
Parameters:
  ds - the DataSource to use
Parameters:
  incrementerName - the name of the sequence/table to use
Parameters:
  columnName - the name of the column in the sequence table to use



DerbyMaxValueIncrementer
public DerbyMaxValueIncrementer(DataSource ds, String incrementerName, String columnName, String dummyName)(Code)
Convenience constructor.
Parameters:
  ds - the DataSource to use
Parameters:
  incrementerName - the name of the sequence/table to use
Parameters:
  columnName - the name of the column in the sequence table to use
Parameters:
  dummyName - the name of the dummy column used for inserts




Method Detail
afterPropertiesSet
public void afterPropertiesSet()(Code)



getCacheSize
public int getCacheSize()(Code)
Return the number of buffered keys.



getColumnName
public String getColumnName()(Code)
Return the name of the column in the sequence table.



getDummyName
public String getDummyName()(Code)
Return the name of the dummy column.



getNextKey
protected synchronized long getNextKey() throws DataAccessException(Code)



setCacheSize
public void setCacheSize(int cacheSize)(Code)
Set the number of buffered keys.



setColumnName
public void setColumnName(String columnName)(Code)
Set the name of the column in the sequence table.



setDummyName
public void setDummyName(String dummyName)(Code)
Set the name of the dummy column.



Fields inherited from org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer
protected int paddingLength(Code)(Java Doc)

Methods inherited from org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer
public void afterPropertiesSet()(Code)(Java Doc)
public DataSource getDataSource()(Code)(Java Doc)
public String getIncrementerName()(Code)(Java Doc)
abstract protected long getNextKey()(Code)(Java Doc)
public int getPaddingLength()(Code)(Java Doc)
public int nextIntValue() throws DataAccessException(Code)(Java Doc)
public long nextLongValue() throws DataAccessException(Code)(Java Doc)
public String nextStringValue() throws DataAccessException(Code)(Java Doc)
public void setDataSource(DataSource dataSource)(Code)(Java Doc)
public void setIncrementerName(String incrementerName)(Code)(Java Doc)
public void setPaddingLength(int paddingLength)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.