MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BigIntegerTypesTest.java
1 /*
2  Copyright 2010 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 package testsuite.clusterj;
20 
21 import java.math.BigDecimal;
22 import java.math.BigInteger;
23 import java.sql.PreparedStatement;
24 import java.sql.ResultSet;
25 import java.sql.SQLException;
26 
27 import testsuite.clusterj.model.BigIntegerTypes;
28 import testsuite.clusterj.model.IdBase;
29 
31 
51  public void testWriteJDBCReadNDB() {
53  failOnError();
54  }
55 
57  public void testWriteNDBReadJDBC() {
59  failOnError();
60  }
61 
62  static int NUMBER_OF_INSTANCES = 10;
63 
64  @Override
65  protected boolean getDebug() {
66  return false;
67  }
68 
69  @Override
70  protected int getNumberOfInstances() {
71  return NUMBER_OF_INSTANCES;
72  }
73 
74  @Override
75  protected String getTableName() {
76  return "bigintegertypes";
77  }
78 
80  @Override
81  Class<? extends IdBase> getModelClass() {
82  return BigIntegerTypes.class;
83  }
84 
86  @Override
87  protected Object getColumnValue(int i, int j) {
88  return BigInteger.valueOf(100000 * i + j);
89  }
90 
91  static ColumnDescriptor decimal_null_hash = new ColumnDescriptor
92  ("decimal_null_hash", new InstanceHandler() {
93  public void setFieldValue(IdBase instance, Object value) {
94  ((BigIntegerTypes)instance).setDecimal_null_hash((BigInteger)value);
95  }
96  public Object getFieldValue(IdBase instance) {
97  return ((BigIntegerTypes)instance).getDecimal_null_hash();
98  }
99  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
100  throws SQLException {
101  preparedStatement.setBigDecimal(j, new BigDecimal((BigInteger)value));
102  }
103  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
104  return rs.getBigDecimal(j).toBigIntegerExact();
105  }
106  });
107 
108  static ColumnDescriptor decimal_null_btree = new ColumnDescriptor
109  ("decimal_null_btree", new InstanceHandler() {
110  public void setFieldValue(IdBase instance, Object value) {
111  ((BigIntegerTypes)instance).setDecimal_null_btree((BigInteger)value);
112  }
113  public Object getFieldValue(IdBase instance) {
114  return ((BigIntegerTypes)instance).getDecimal_null_btree();
115  }
116  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
117  throws SQLException {
118  preparedStatement.setBigDecimal(j, new BigDecimal((BigInteger)value));
119  }
120  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
121  return rs.getBigDecimal(j).toBigIntegerExact();
122  }
123  });
124  static ColumnDescriptor decimal_null_both = new ColumnDescriptor
125  ("decimal_null_both", new InstanceHandler() {
126  public void setFieldValue(IdBase instance, Object value) {
127  ((BigIntegerTypes)instance).setDecimal_null_both((BigInteger)value);
128  }
129  public BigInteger getFieldValue(IdBase instance) {
130  return ((BigIntegerTypes)instance).getDecimal_null_both();
131  }
132  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
133  throws SQLException {
134  preparedStatement.setBigDecimal(j, new BigDecimal((BigInteger)value));
135  }
136  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
137  return rs.getBigDecimal(j).toBigIntegerExact();
138  }
139  });
140  static ColumnDescriptor decimal_null_none = new ColumnDescriptor
141  ("decimal_null_none", new InstanceHandler() {
142  public void setFieldValue(IdBase instance, Object value) {
143  ((BigIntegerTypes)instance).setDecimal_null_none((BigInteger)value);
144  }
145  public BigInteger getFieldValue(IdBase instance) {
146  return ((BigIntegerTypes)instance).getDecimal_null_none();
147  }
148  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
149  throws SQLException {
150  preparedStatement.setBigDecimal(j, new BigDecimal((BigInteger)value));
151  }
152  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
153  return rs.getBigDecimal(j).toBigIntegerExact();
154  }
155  });
156 
157  protected static ColumnDescriptor[] columnDescriptors = new ColumnDescriptor[] {
158  decimal_null_hash,
159  decimal_null_btree,
160  decimal_null_both,
161  decimal_null_none
162  };
163 
164  @Override
165  protected ColumnDescriptor[] getColumnDescriptors() {
166  return columnDescriptors;
167  }
168 
169 }