提交 6216db17 authored 作者: Thomas Mueller's avatar Thomas Mueller

Cleanup:

- Fix missing or incorrectly formatted license headers
- Line comments are lowercase except for complete sentences
- Remove trailing whitespace (the IDE should fix this)
上级 8a7312b8
/* /*
* Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License, Version * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
* 1.0, and under the Eclipse Public License, Version 1.0 * Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group * (http://h2database.com/html/license.html).
*/ * Initial Developer: James Moger
package org.h2.test.jaqu; */
package org.h2.test.jaqu;
// ## Java 1.5 begin ##
import java.util.Arrays; //## Java 1.5 begin ##
import java.util.List; import java.util.Arrays;
import org.h2.jaqu.Table.JQColumn; import java.util.List;
import org.h2.jaqu.Table.JQIndex; import org.h2.jaqu.Table.JQColumn;
import org.h2.jaqu.Table.JQTable; import org.h2.jaqu.Table.JQIndex;
import org.h2.jaqu.Table.JQTable;
/**
* A table containing product data. /**
*/ * A table containing product data.
// ## Java 1.5 begin ## */
@JQTable(name = "AnnotatedProduct", primaryKey = "id") //## Java 1.5 begin ##
@JQIndex(standard = "name, cat") @JQTable(name = "AnnotatedProduct", primaryKey = "id")
public class ProductAnnotationOnly { @JQIndex(standard = "name, cat")
public class ProductAnnotationOnly {
@JQColumn(autoIncrement = true)
public Integer autoIncrement; @JQColumn(autoIncrement = true)
public Integer autoIncrement;
public String unmappedField;
public String unmappedField;
@JQColumn(name = "id")
Integer productId; @JQColumn(name = "id")
Integer productId;
@JQColumn(name = "cat", maxLength = 15, trimString = true)
String category; @JQColumn(name = "cat", maxLength = 15, trimString = true)
String category;
@JQColumn(name = "name")
private String productName; @JQColumn(name = "name")
private String productName;
@SuppressWarnings("unused")
@JQColumn @SuppressWarnings("unused")
private Double unitPrice; @JQColumn
private Double unitPrice;
@JQColumn
private Integer unitsInStock; @JQColumn
private Integer unitsInStock;
public ProductAnnotationOnly() {
// public constructor public ProductAnnotationOnly() {
} // public constructor
}
private ProductAnnotationOnly(int productId, String productName, String category, double unitPrice,
int unitsInStock, String unmappedField) { private ProductAnnotationOnly(int productId, String productName, String category, double unitPrice,
this.productId = productId; int unitsInStock, String unmappedField) {
this.productName = productName; this.productId = productId;
this.category = category; this.productName = productName;
this.unitPrice = unitPrice; this.category = category;
this.unitsInStock = unitsInStock; this.unitPrice = unitPrice;
this.unmappedField = unmappedField; this.unitsInStock = unitsInStock;
} this.unmappedField = unmappedField;
}
private static ProductAnnotationOnly create(int productId, String productName, String category, double unitPrice,
int unitsInStock, String unmappedField) { private static ProductAnnotationOnly create(int productId, String productName, String category, double unitPrice,
return new ProductAnnotationOnly(productId, productName, category, unitPrice, unitsInStock, unmappedField); int unitsInStock, String unmappedField) {
} return new ProductAnnotationOnly(productId, productName, category, unitPrice, unitsInStock, unmappedField);
}
public static List<ProductAnnotationOnly> getList() {
String unmappedField = "unmapped"; public static List<ProductAnnotationOnly> getList() {
ProductAnnotationOnly[] list = { create(1, "Chai", "Beverages", 18, 39, unmappedField), String unmappedField = "unmapped";
create(2, "Chang", "Beverages", 19.0, 17, unmappedField), ProductAnnotationOnly[] list = { create(1, "Chai", "Beverages", 18, 39, unmappedField),
create(3, "Aniseed Syrup", "Condiments", 10.0, 13, unmappedField), create(2, "Chang", "Beverages", 19.0, 17, unmappedField),
create(4, "Chef Anton's Cajun Seasoning", "Condiments", 22.0, 53, unmappedField), create(3, "Aniseed Syrup", "Condiments", 10.0, 13, unmappedField),
create(5, "Chef Anton's Gumbo Mix", "Condiments", 21.3500, 0, unmappedField), create(4, "Chef Anton's Cajun Seasoning", "Condiments", 22.0, 53, unmappedField),
create(6, "Grandma's Boysenberry Spread", "Condiments", 25.0, 120, unmappedField), create(5, "Chef Anton's Gumbo Mix", "Condiments", 21.3500, 0, unmappedField),
create(7, "Uncle Bob's Organic Dried Pears", "Produce", 30.0, 15, unmappedField), create(6, "Grandma's Boysenberry Spread", "Condiments", 25.0, 120, unmappedField),
create(8, "Northwoods Cranberry Sauce", "Condiments", 40.0, 6, unmappedField), create(7, "Uncle Bob's Organic Dried Pears", "Produce", 30.0, 15, unmappedField),
create(9, "Mishi Kobe Niku", "Meat/Poultry", 97.0, 29, unmappedField), create(8, "Northwoods Cranberry Sauce", "Condiments", 40.0, 6, unmappedField),
create(10, "Ikura", "Seafood", 31.0, 31, unmappedField), }; create(9, "Mishi Kobe Niku", "Meat/Poultry", 97.0, 29, unmappedField),
return Arrays.asList(list); create(10, "Ikura", "Seafood", 31.0, 31, unmappedField), };
} return Arrays.asList(list);
}
public String toString() {
return productName + ": " + unitsInStock; public String toString() {
} return productName + ": " + unitsInStock;
}
}
// ## Java 1.5 end ## }
//## Java 1.5 end ##
package org.h2.test.jaqu; /*
* Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
import java.util.Arrays; * Version 1.0, and under the Eclipse Public License, Version 1.0
import java.util.List; * (http://h2database.com/html/license.html).
import org.h2.jaqu.Table.JQTable; * Initial Developer: James Moger
*/
/** package org.h2.test.jaqu;
* This class inherits all its fields from a parent class which has annotated
* columns. The JQTable annotation of the parent class is ignored and only import java.util.Arrays;
* the JQTable annotation of this class matters. import java.util.List;
* However, this table inherits JQColumns from its super class. import org.h2.jaqu.Table.JQTable;
*/
@JQTable(inheritColumns = true, annotationsOnly = false) /**
public class ProductInheritedAnnotation extends ProductMixedAnnotation { * This class inherits all its fields from a parent class which has annotated
* columns. The JQTable annotation of the parent class is ignored and only
public ProductInheritedAnnotation() { * the JQTable annotation of this class matters.
// public constructor * However, this table inherits JQColumns from its super class.
} */
@JQTable(inheritColumns = true, annotationsOnly = false)
private ProductInheritedAnnotation(int productId, String productName, String category, double unitPrice, public class ProductInheritedAnnotation extends ProductMixedAnnotation {
int unitsInStock, String mappedField) {
super(productId, productName, category, unitPrice, unitsInStock, mappedField); public ProductInheritedAnnotation() {
} // public constructor
}
private static ProductInheritedAnnotation create(int productId, String productName, String category,
double unitPrice, int unitsInStock, String mappedField) { private ProductInheritedAnnotation(int productId, String productName, String category, double unitPrice,
return new ProductInheritedAnnotation(productId, productName, category, unitPrice, unitsInStock, mappedField); int unitsInStock, String mappedField) {
} super(productId, productName, category, unitPrice, unitsInStock, mappedField);
}
public static List<ProductInheritedAnnotation> getData() {
String mappedField = "mapped"; private static ProductInheritedAnnotation create(int productId, String productName, String category,
ProductInheritedAnnotation[] list = { create(1, "Chai", "Beverages", 18, 39, mappedField), double unitPrice, int unitsInStock, String mappedField) {
create(2, "Chang", "Beverages", 19.0, 17, mappedField), return new ProductInheritedAnnotation(productId, productName, category, unitPrice, unitsInStock, mappedField);
create(3, "Aniseed Syrup", "Condiments", 10.0, 13, mappedField), }
create(4, "Chef Anton's Cajun Seasoning", "Condiments", 22.0, 53, mappedField),
create(5, "Chef Anton's Gumbo Mix", "Condiments", 21.3500, 0, mappedField), public static List<ProductInheritedAnnotation> getData() {
create(6, "Grandma's Boysenberry Spread", "Condiments", 25.0, 120, mappedField), String mappedField = "mapped";
create(7, "Uncle Bob's Organic Dried Pears", "Produce", 30.0, 15, mappedField), ProductInheritedAnnotation[] list = { create(1, "Chai", "Beverages", 18, 39, mappedField),
create(8, "Northwoods Cranberry Sauce", "Condiments", 40.0, 6, mappedField), create(2, "Chang", "Beverages", 19.0, 17, mappedField),
create(9, "Mishi Kobe Niku", "Meat/Poultry", 97.0, 29, mappedField), create(3, "Aniseed Syrup", "Condiments", 10.0, 13, mappedField),
create(10, "Ikura", "Seafood", 31.0, 31, mappedField), }; create(4, "Chef Anton's Cajun Seasoning", "Condiments", 22.0, 53, mappedField),
return Arrays.asList(list); create(5, "Chef Anton's Gumbo Mix", "Condiments", 21.3500, 0, mappedField),
} create(6, "Grandma's Boysenberry Spread", "Condiments", 25.0, 120, mappedField),
create(7, "Uncle Bob's Organic Dried Pears", "Produce", 30.0, 15, mappedField),
} create(8, "Northwoods Cranberry Sauce", "Condiments", 40.0, 6, mappedField),
create(9, "Mishi Kobe Niku", "Meat/Poultry", 97.0, 29, mappedField),
create(10, "Ikura", "Seafood", 31.0, 31, mappedField), };
return Arrays.asList(list);
}
}
/* /*
* Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License, Version * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
* 1.0, and under the Eclipse Public License, Version 1.0 * Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group * (http://h2database.com/html/license.html).
*/ * Initial Developer: James Moger
package org.h2.test.jaqu; */
package org.h2.test.jaqu;
// ## Java 1.5 begin ##
import java.util.Arrays; //## Java 1.5 begin ##
import java.util.List; import java.util.Arrays;
import org.h2.jaqu.Table.JQColumn; import java.util.List;
import org.h2.jaqu.Table.JQIndex; import org.h2.jaqu.Table.JQColumn;
import org.h2.jaqu.Table.JQTable; import org.h2.jaqu.Table.JQIndex;
import org.h2.jaqu.Table.JQTable;
/**
* A table containing product data. /**
*/ * A table containing product data.
// ## Java 1.5 begin ## */
@JQTable(annotationsOnly = false) //## Java 1.5 begin ##
@JQIndex(standard = "name, cat") @JQTable(annotationsOnly = false)
public class ProductMixedAnnotation { @JQIndex(standard = "name, cat")
public class ProductMixedAnnotation {
public Double unitPrice;
public Integer unitsInStock; public Double unitPrice;
public String mappedField; public Integer unitsInStock;
public String mappedField;
@JQColumn(name = "cat", maxLength = 255)
String category; @JQColumn(name = "cat", maxLength = 255)
String category;
@JQColumn(name = "id", primaryKey = true)
private Integer productId; @JQColumn(name = "id", primaryKey = true)
private Integer productId;
@JQColumn(name = "name")
private String productName; @JQColumn(name = "name")
private String productName;
public ProductMixedAnnotation() {
// public constructor public ProductMixedAnnotation() {
} // public constructor
}
protected ProductMixedAnnotation(int productId, String productName, String category, double unitPrice,
int unitsInStock, String mappedField) { protected ProductMixedAnnotation(int productId, String productName, String category, double unitPrice,
this.productId = productId; int unitsInStock, String mappedField) {
this.productName = productName; this.productId = productId;
this.category = category; this.productName = productName;
this.unitPrice = unitPrice; this.category = category;
this.unitsInStock = unitsInStock; this.unitPrice = unitPrice;
this.mappedField = mappedField; this.unitsInStock = unitsInStock;
} this.mappedField = mappedField;
}
private static ProductMixedAnnotation create(int productId, String productName, String category, double unitPrice,
int unitsInStock, String mappedField) { private static ProductMixedAnnotation create(int productId, String productName, String category, double unitPrice,
return new ProductMixedAnnotation(productId, productName, category, unitPrice, unitsInStock, mappedField); int unitsInStock, String mappedField) {
} return new ProductMixedAnnotation(productId, productName, category, unitPrice, unitsInStock, mappedField);
}
public static List<ProductMixedAnnotation> getList() {
String mappedField = "mapped"; public static List<ProductMixedAnnotation> getList() {
ProductMixedAnnotation[] list = { create(1, "Chai", "Beverages", 18, 39, mappedField), String mappedField = "mapped";
create(2, "Chang", "Beverages", 19.0, 17, mappedField), ProductMixedAnnotation[] list = { create(1, "Chai", "Beverages", 18, 39, mappedField),
create(3, "Aniseed Syrup", "Condiments", 10.0, 13, mappedField), create(2, "Chang", "Beverages", 19.0, 17, mappedField),
create(4, "Chef Anton's Cajun Seasoning", "Condiments", 22.0, 53, mappedField), create(3, "Aniseed Syrup", "Condiments", 10.0, 13, mappedField),
create(5, "Chef Anton's Gumbo Mix", "Condiments", 21.3500, 0, mappedField), create(4, "Chef Anton's Cajun Seasoning", "Condiments", 22.0, 53, mappedField),
create(6, "Grandma's Boysenberry Spread", "Condiments", 25.0, 120, mappedField), create(5, "Chef Anton's Gumbo Mix", "Condiments", 21.3500, 0, mappedField),
create(7, "Uncle Bob's Organic Dried Pears", "Produce", 30.0, 15, mappedField), create(6, "Grandma's Boysenberry Spread", "Condiments", 25.0, 120, mappedField),
create(8, "Northwoods Cranberry Sauce", "Condiments", 40.0, 6, mappedField), create(7, "Uncle Bob's Organic Dried Pears", "Produce", 30.0, 15, mappedField),
create(9, "Mishi Kobe Niku", "Meat/Poultry", 97.0, 29, mappedField), create(8, "Northwoods Cranberry Sauce", "Condiments", 40.0, 6, mappedField),
create(10, "Ikura", "Seafood", 31.0, 31, mappedField), }; create(9, "Mishi Kobe Niku", "Meat/Poultry", 97.0, 29, mappedField),
return Arrays.asList(list); create(10, "Ikura", "Seafood", 31.0, 31, mappedField), };
} return Arrays.asList(list);
}
public String toString() {
return productName + ": " + unitsInStock; public String toString() {
} return productName + ": " + unitsInStock;
}
public int id() {
return productId; public int id() {
} return productId;
}
public String name() {
return productName; public String name() {
} return productName;
}
}
// ## Java 1.5 end ## }
//## Java 1.5 end ##
/* /*
* Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License, Version * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
* 1.0, and under the Eclipse Public License, Version 1.0 * Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group * (http://h2database.com/html/license.html).
*/ * Initial Developer: James Moger
package org.h2.test.jaqu; */
package org.h2.test.jaqu;
// ## Java 1.5 begin ##
import java.util.Arrays; //## Java 1.5 begin ##
import java.util.List; import java.util.Arrays;
import org.h2.jaqu.Table.JQColumn; import java.util.List;
import org.h2.jaqu.Table.JQTable; import org.h2.jaqu.Table.JQColumn;
import org.h2.jaqu.Table.JQTable;
/** //## Java 1.5 end ##
* A table containing product data.
*/ /**
// ## Java 1.5 begin ## * A table containing product data.
@JQTable(createIfRequired = false) */
public class ProductNoCreateTable { //## Java 1.5 begin ##
@JQTable(createIfRequired = false)
@SuppressWarnings("unused") public class ProductNoCreateTable {
@JQColumn(name = "id")
private Integer productId; @SuppressWarnings("unused")
@JQColumn(name = "id")
@SuppressWarnings("unused") private Integer productId;
@JQColumn(name = "name")
private String productName; @SuppressWarnings("unused")
@JQColumn(name = "name")
public ProductNoCreateTable() { private String productName;
// public constructor
} public ProductNoCreateTable() {
// public constructor
private ProductNoCreateTable(int productId, String productName) { }
this.productId = productId;
this.productName = productName; private ProductNoCreateTable(int productId, String productName) {
} this.productId = productId;
this.productName = productName;
private static ProductNoCreateTable create(int productId, String productName) { }
return new ProductNoCreateTable(productId, productName);
} private static ProductNoCreateTable create(int productId, String productName) {
return new ProductNoCreateTable(productId, productName);
public static List<ProductNoCreateTable> getList() { }
ProductNoCreateTable[] list = { create(1, "Chai"), create(2, "Chang") };
return Arrays.asList(list); public static List<ProductNoCreateTable> getList() {
} ProductNoCreateTable[] list = { create(1, "Chai"), create(2, "Chang") };
return Arrays.asList(list);
} }
// ## Java 1.5 end ##
}
//## Java 1.5 end ##
...@@ -386,7 +386,7 @@ public class SamplesTest extends TestBase { ...@@ -386,7 +386,7 @@ public class SamplesTest extends TestBase {
assertEquals(1, count); assertEquals(1, count);
} }
private void testLimitOffset() { private void testLimitOffset() {
Set<Integer> ids = new HashSet<Integer>(); Set<Integer> ids = new HashSet<Integer>();
Product p = new Product(); Product p = new Product();
...@@ -398,7 +398,7 @@ public class SamplesTest extends TestBase { ...@@ -398,7 +398,7 @@ public class SamplesTest extends TestBase {
} }
} }
} }
private void testKeyRetrieval() { private void testKeyRetrieval() {
List<SupportedTypes> list = SupportedTypes.createList(); List<SupportedTypes> list = SupportedTypes.createList();
List<Long> keys = db.insertAllAndGetKeys(list); List<Long> keys = db.insertAllAndGetKeys(list);
...@@ -406,7 +406,7 @@ public class SamplesTest extends TestBase { ...@@ -406,7 +406,7 @@ public class SamplesTest extends TestBase {
for (Long l : keys) { for (Long l : keys) {
assertTrue("Failed to add key. Duplicate?", uniqueKeys.add(l)); assertTrue("Failed to add key. Duplicate?", uniqueKeys.add(l));
} }
} }
//## Java 1.5 end ## //## Java 1.5 end ##
/** /**
......
package org.h2.test.jaqu; /*
* Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
import java.math.BigDecimal; * Version 1.0, and under the Eclipse Public License, Version 1.0
import java.util.List; * (http://h2database.com/html/license.html).
import java.util.Random; * Initial Developer: James Moger
import org.h2.jaqu.Table.JQColumn; */
import org.h2.jaqu.Table.JQTable; package org.h2.test.jaqu;
import org.h2.util.New;
import java.math.BigDecimal;
/** import java.util.List;
* A data class that contains a column for each data type. import java.util.Random;
*/ import org.h2.jaqu.Table.JQColumn;
@JQTable(strictTypeMapping = true, version = 1) import org.h2.jaqu.Table.JQTable;
public class SupportedTypes { import org.h2.util.New;
static final SupportedTypes SAMPLE = new SupportedTypes(); /**
* A data class that contains a column for each data type.
@JQColumn(primaryKey = true, autoIncrement = true) */
public Integer id; @JQTable(strictTypeMapping = true, version = 1)
public class SupportedTypes {
@JQColumn
private Boolean myBool = false; static final SupportedTypes SAMPLE = new SupportedTypes();
@JQColumn @JQColumn(primaryKey = true, autoIncrement = true)
private Byte myByte = 2; public Integer id;
@JQColumn @JQColumn
private Short myShort; private Boolean myBool = false;
@JQColumn @JQColumn
private Integer myInteger; private Byte myByte = 2;
@JQColumn @JQColumn
private Long myLong; private Short myShort;
@JQColumn @JQColumn
private Float myFloat = 1.0f; private Integer myInteger;
@JQColumn @JQColumn
private Double myDouble; private Long myLong;
@JQColumn @JQColumn
private BigDecimal myBigDecimal; private Float myFloat = 1.0f;
@JQColumn @JQColumn
private String myString; private Double myDouble;
@JQColumn @JQColumn
private java.util.Date myUtilDate; private BigDecimal myBigDecimal;
@JQColumn @JQColumn
private java.sql.Date mySqlDate; private String myString;
@JQColumn @JQColumn
private java.sql.Time mySqlTime; private java.util.Date myUtilDate;
@JQColumn @JQColumn
private java.sql.Timestamp mySqlTimestamp; private java.sql.Date mySqlDate;
static List<SupportedTypes> createList() { @JQColumn
List<SupportedTypes> list = New.arrayList(); private java.sql.Time mySqlTime;
for (int i = 0; i < 10; i++) {
list.add(randomValue()); @JQColumn
} private java.sql.Timestamp mySqlTimestamp;
return list;
} static List<SupportedTypes> createList() {
List<SupportedTypes> list = New.arrayList();
static SupportedTypes randomValue() { for (int i = 0; i < 10; i++) {
Random rand = new Random(); list.add(randomValue());
SupportedTypes s = new SupportedTypes(); }
s.myBool = new Boolean(rand.nextBoolean()); return list;
s.myByte = new Byte((byte) rand.nextInt(Byte.MAX_VALUE)); }
s.myShort = new Short((short) rand.nextInt(Short.MAX_VALUE));
s.myInteger = new Integer(rand.nextInt()); static SupportedTypes randomValue() {
s.myLong = new Long(rand.nextLong()); Random rand = new Random();
s.myFloat = new Float(rand.nextFloat()); SupportedTypes s = new SupportedTypes();
s.myDouble = new Double(rand.nextDouble()); s.myBool = new Boolean(rand.nextBoolean());
s.myBigDecimal = new BigDecimal(rand.nextDouble()); s.myByte = new Byte((byte) rand.nextInt(Byte.MAX_VALUE));
s.myString = Long.toHexString(rand.nextLong()); s.myShort = new Short((short) rand.nextInt(Short.MAX_VALUE));
s.myUtilDate = new java.util.Date(rand.nextLong()); s.myInteger = new Integer(rand.nextInt());
s.mySqlDate = new java.sql.Date(rand.nextLong()); s.myLong = new Long(rand.nextLong());
s.mySqlTime = new java.sql.Time(rand.nextLong()); s.myFloat = new Float(rand.nextFloat());
s.mySqlTimestamp = new java.sql.Timestamp(rand.nextLong()); s.myDouble = new Double(rand.nextDouble());
return s; s.myBigDecimal = new BigDecimal(rand.nextDouble());
} s.myString = Long.toHexString(rand.nextLong());
s.myUtilDate = new java.util.Date(rand.nextLong());
public boolean equivalentTo(SupportedTypes s) { s.mySqlDate = new java.sql.Date(rand.nextLong());
boolean same = true; s.mySqlTime = new java.sql.Time(rand.nextLong());
same &= myBool.equals(s.myBool); s.mySqlTimestamp = new java.sql.Timestamp(rand.nextLong());
same &= myByte.equals(s.myByte); return s;
same &= myShort.equals(s.myShort); }
same &= myInteger.equals(s.myInteger);
same &= myLong.equals(s.myLong); public boolean equivalentTo(SupportedTypes s) {
same &= myFloat.equals(s.myFloat); boolean same = true;
same &= myDouble.equals(s.myDouble); same &= myBool.equals(s.myBool);
same &= myBigDecimal.equals(s.myBigDecimal); same &= myByte.equals(s.myByte);
same &= myUtilDate.getTime() == s.myUtilDate.getTime(); same &= myShort.equals(s.myShort);
same &= mySqlTimestamp.getTime() == s.mySqlTimestamp.getTime(); same &= myInteger.equals(s.myInteger);
same &= mySqlDate.toString().equals(s.mySqlDate.toString()); same &= myLong.equals(s.myLong);
same &= mySqlTime.toString().equals(s.mySqlTime.toString()); same &= myFloat.equals(s.myFloat);
same &= myString.equals(s.myString); same &= myDouble.equals(s.myDouble);
return same; same &= myBigDecimal.equals(s.myBigDecimal);
} same &= myUtilDate.getTime() == s.myUtilDate.getTime();
same &= mySqlTimestamp.getTime() == s.mySqlTimestamp.getTime();
/** same &= mySqlDate.toString().equals(s.mySqlDate.toString());
* Class to demonstrate TableUpdater same &= mySqlTime.toString().equals(s.mySqlTime.toString());
* same &= myString.equals(s.myString);
*/ return same;
@JQTable(name = "SupportedTypes", version = 2, inheritColumns = true, strictTypeMapping = true) }
public static class SupportedTypes2 extends SupportedTypes {
/**
public SupportedTypes2() { * Class to demonstrate TableUpdater
// nothing to do *
} */
} @JQTable(name = "SupportedTypes", version = 2, inheritColumns = true, strictTypeMapping = true)
} public static class SupportedTypes2 extends SupportedTypes {
public SupportedTypes2() {
// nothing to do
}
}
}
...@@ -18,7 +18,7 @@ import static java.sql.Date.valueOf; ...@@ -18,7 +18,7 @@ import static java.sql.Date.valueOf;
*/ */
public class UpdateTest extends TestBase { public class UpdateTest extends TestBase {
Db db; private Db db;
/** /**
* This method is called when executing this application from the command * This method is called when executing this application from the command
...@@ -112,11 +112,11 @@ public class UpdateTest extends TestBase { ...@@ -112,11 +112,11 @@ public class UpdateTest extends TestBase {
ourOrder.orderDate = valueOf("2007-01-02"); ourOrder.orderDate = valueOf("2007-01-02");
db.merge(ourOrder); db.merge(ourOrder);
} }
private void testSetColumns() { private void testSetColumns() {
Product p = new Product(); Product p = new Product();
Product original = db.from(p).where(p.productId).is(1).selectFirst(); Product original = db.from(p).where(p.productId).is(1).selectFirst();
// update string and double columns // update string and double columns
db.from(p) db.from(p)
.set(p.productName).to("updated") .set(p.productName).to("updated")
...@@ -125,9 +125,9 @@ public class UpdateTest extends TestBase { ...@@ -125,9 +125,9 @@ public class UpdateTest extends TestBase {
.where(p.productId) .where(p.productId)
.is(1). .is(1).
update(); update();
// confirm the data was properly updated // confirm the data was properly updated
Product revised = db.from(p).where(p.productId).is(1).selectFirst(); Product revised = db.from(p).where(p.productId).is(1).selectFirst();
assertEquals("updated", revised.productName); assertEquals("updated", revised.productName);
assertEquals(original.unitPrice + 3.14, revised.unitPrice); assertEquals(original.unitPrice + 3.14, revised.unitPrice);
assertEquals(original.unitsInStock + 2, revised.unitsInStock.intValue()); assertEquals(original.unitsInStock + 2, revised.unitsInStock.intValue());
...@@ -138,12 +138,12 @@ public class UpdateTest extends TestBase { ...@@ -138,12 +138,12 @@ public class UpdateTest extends TestBase {
.set(p.unitPrice).to(original.unitPrice) .set(p.unitPrice).to(original.unitPrice)
.increment(p.unitsInStock).by(-2) .increment(p.unitsInStock).by(-2)
.where(p.productId).is(1).update(); .where(p.productId).is(1).update();
// confirm the data was properly restored // confirm the data was properly restored
Product restored = db.from(p).where(p.productId).is(1).selectFirst(); Product restored = db.from(p).where(p.productId).is(1).selectFirst();
assertEquals(original.productName, restored.productName); assertEquals(original.productName, restored.productName);
assertEquals(original.unitPrice, restored.unitPrice); assertEquals(original.unitPrice, restored.unitPrice);
assertEquals(original.unitsInStock, restored.unitsInStock); assertEquals(original.unitsInStock, restored.unitsInStock);
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论