├── .gitignore ├── DaoExample ├── .gitignore ├── libs │ └── greenDAO.jar ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── docs │ └── greenDAO-javadoc.jar ├── res │ ├── drawable-hdpi │ │ └── icon.png │ ├── drawable-ldpi │ │ └── icon.png │ ├── drawable-mdpi │ │ └── icon.png │ ├── values │ │ └── strings.xml │ └── layout │ │ └── main.xml ├── project.properties ├── src-gen │ └── de │ │ └── greenrobot │ │ └── daoexample │ │ ├── Customer.java │ │ ├── Order.java │ │ ├── Note.java │ │ ├── DaoSession.java │ │ └── DaoMaster.java ├── .classpath ├── AndroidManifest.xml ├── .project ├── src-test │ └── de │ │ └── greenrobot │ │ └── daoexample │ │ ├── NoteTest.java │ │ └── CustomerOrderTest.java └── proguard.cfg ├── DaoExampleGenerator ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── .project ├── .classpath └── src │ └── de │ └── greenrobot │ └── daogenerator │ └── gentest │ └── ExampleDaoGenerator.java ├── DaoTest ├── .gitignore ├── res │ └── values │ │ └── dummy.xml ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ └── de │ │ └── greenrobot │ │ ├── daotest │ │ ├── TestSuperclass.java │ │ ├── TestInterface.java │ │ ├── query │ │ │ ├── QueryBuilderOrderTest.java │ │ │ └── CountQueryTest.java │ │ ├── entity │ │ │ ├── SqliteMasterTest.java │ │ │ ├── StringKeyValueEntityTest.java │ │ │ ├── ExtendsImplementsEntityTest.java │ │ │ ├── AutoincrementEntityTest.java │ │ │ ├── AbcdefEntityTest.java │ │ │ ├── SpecialNamesEntityTest.java │ │ │ ├── ToManyTargetEntityTest.java │ │ │ ├── SimpleEntityNotNullHelper.java │ │ │ ├── TestEntityTest.java │ │ │ ├── DateEntityTest.java │ │ │ ├── TestEntityTestBase.java │ │ │ ├── TestEntityIdentityScopeTest.java │ │ │ ├── StringKeyValueEntityIdentityScopeTest.java │ │ │ ├── TreeEntityTest.java │ │ │ └── AnActiveEntityTest.java │ │ ├── StandardApplicationTest.java │ │ ├── performance │ │ │ ├── PerformanceTestNotNullIdentityScope.java │ │ │ └── PerformanceTestNotNull.java │ │ ├── DbUtilsTest.java │ │ ├── IndexTest.java │ │ ├── DaoSessionTest.java │ │ └── LongHashMapTest.java │ │ └── daotest2 │ │ └── entity │ │ └── KeepEntityTest.java ├── assets │ └── minimal-entity.sql ├── .classpath ├── project.properties ├── AndroidManifest.xml ├── src-gen │ └── de │ │ └── greenrobot │ │ ├── daotest │ │ ├── AutoincrementEntity.java │ │ ├── StringKeyValueEntity.java │ │ ├── ExtendsImplementsEntity.java │ │ ├── DateEntity.java │ │ ├── ToManyTargetEntity.java │ │ ├── SqliteMaster.java │ │ ├── AnActiveEntity.java │ │ ├── SpecialNamesEntity.java │ │ ├── AbcdefEntity.java │ │ └── SimpleEntity.java │ │ └── daotest2 │ │ ├── to1_specialentity │ │ └── ToOneTarget2.java │ │ ├── KeepEntity.java │ │ ├── ToManyTarget2.java │ │ └── dao │ │ ├── DaoMaster.java │ │ ├── KeepEntityDao.java │ │ └── DaoSession.java ├── .project └── proguard.cfg ├── PerformanceTestOrmLite ├── .gitignore ├── .settings │ └── org.eclipse.core.resources.prefs ├── lib │ ├── ormlite-core-4.34-SNAPSHOT.jar │ └── ormlite-android-4.34-SNAPSHOT.jar ├── project.properties ├── AndroidManifest.xml ├── src │ └── de │ │ └── greenrobot │ │ └── performance │ │ └── ormlite │ │ ├── MinimalEntity.java │ │ ├── SimpleEntityNotNullHelper.java │ │ ├── DbHelper.java │ │ └── SimpleEntityNotNull.java ├── .classpath ├── .project └── proguard.cfg ├── DaoCore ├── .gitignore ├── res │ └── values │ │ └── dummy.xml ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── libs │ └── commons-lang3-3.0.1.jar ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── NOTICE ├── AndroidManifest.xml ├── src │ └── de │ │ └── greenrobot │ │ └── dao │ │ ├── annotations │ │ └── SerializedField.java │ │ ├── IdentityScopeType.java │ │ ├── CountQuery.java │ │ ├── CloseableListIterator.java │ │ ├── Command.java │ │ ├── IdentityScope.java │ │ ├── test │ │ ├── AbstractDaoTestStringPk.java │ │ ├── AbstractDaoTestLongPk.java │ │ ├── AbstractDaoSessionTest.java │ │ ├── DbTest.java │ │ └── AbstractDaoTest.java │ │ ├── DaoException.java │ │ ├── AbstractDaoMaster.java │ │ ├── UnitTestDaoAccess.java │ │ ├── DeleteQuery.java │ │ ├── AbstractQuery.java │ │ └── DaoLog.java ├── .classpath ├── project.properties ├── proguard-project.txt ├── .project ├── mybuild.xml ├── proguard.cfg ├── build.gradle └── gradlew.bat ├── DaoGenerator ├── .gitignore ├── lib │ └── freemarker.jar ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── performance │ ├── galaxy-nexus.xlsx │ └── performance-data.xlsx ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .project ├── .classpath ├── src-template │ ├── annotation.ftl │ ├── serialize-helper.ftl │ ├── enum-helper.ftl │ ├── dao-unit-test.ftl │ └── entity.ftl ├── src │ └── de │ │ └── greenrobot │ │ └── daogenerator │ │ ├── PropertyType.java │ │ ├── QueryParam.java │ │ ├── Index.java │ │ ├── Query.java │ │ ├── Annotation.java │ │ ├── EnumProperty.java │ │ ├── PropertyOrderList.java │ │ └── DaoUtil.java ├── .freemarker-ide.xml ├── build.gradle ├── gradlew.bat └── src-test │ └── de │ └── greenrobot │ └── daogenerator │ └── test │ └── SimpleDaoGeneratorTest.java ├── .arcconfig └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | local.properties 3 | -------------------------------------------------------------------------------- /DaoExample/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /gen 3 | -------------------------------------------------------------------------------- /DaoExampleGenerator/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | -------------------------------------------------------------------------------- /DaoTest/.gitignore: -------------------------------------------------------------------------------- 1 | /gen 2 | /DaoCore_src 3 | /bin 4 | -------------------------------------------------------------------------------- /PerformanceTestOrmLite/.gitignore: -------------------------------------------------------------------------------- 1 | /gen 2 | /bin 3 | -------------------------------------------------------------------------------- /DaoCore/.gitignore: -------------------------------------------------------------------------------- 1 | /gen 2 | /bin 3 | /release 4 | .gradle 5 | build 6 | -------------------------------------------------------------------------------- /DaoGenerator/.gitignore: -------------------------------------------------------------------------------- 1 | /test-out 2 | /release 3 | /bin 4 | build 5 | .gradle 6 | -------------------------------------------------------------------------------- /DaoExample/libs/greenDAO.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoExample/libs/greenDAO.jar -------------------------------------------------------------------------------- /DaoCore/res/values/dummy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /DaoGenerator/lib/freemarker.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoGenerator/lib/freemarker.jar -------------------------------------------------------------------------------- /DaoTest/res/values/dummy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /DaoCore/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=Cp1252 3 | -------------------------------------------------------------------------------- /DaoTest/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=Cp1252 3 | -------------------------------------------------------------------------------- /DaoCore/libs/commons-lang3-3.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoCore/libs/commons-lang3-3.0.1.jar -------------------------------------------------------------------------------- /DaoExample/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=Cp1252 3 | -------------------------------------------------------------------------------- /DaoExample/docs/greenDAO-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoExample/docs/greenDAO-javadoc.jar -------------------------------------------------------------------------------- /DaoExample/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoExample/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /DaoExample/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoExample/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /DaoExample/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoExample/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /DaoGenerator/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=Cp1252 3 | -------------------------------------------------------------------------------- /DaoExampleGenerator/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=Cp1252 3 | -------------------------------------------------------------------------------- /DaoCore/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoCore/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /DaoGenerator/performance/galaxy-nexus.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoGenerator/performance/galaxy-nexus.xlsx -------------------------------------------------------------------------------- /PerformanceTestOrmLite/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=Cp1252 3 | -------------------------------------------------------------------------------- /.arcconfig: -------------------------------------------------------------------------------- 1 | { 2 | "project_id": "Path GreenDao", 3 | "conduit_uri": "https://phabricator.path.com/", 4 | "immutable_history": false 5 | } 6 | -------------------------------------------------------------------------------- /DaoGenerator/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoGenerator/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /DaoGenerator/performance/performance-data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoGenerator/performance/performance-data.xlsx -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/TestSuperclass.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | public class TestSuperclass { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/TestInterface.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | public interface TestInterface { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /DaoCore/NOTICE: -------------------------------------------------------------------------------- 1 | greenrobot greenDAO 2 | Copyright 2011 greenrobot.de 3 | 4 | This product includes software developed at greenrobot.de (http://greenrobot.de/). -------------------------------------------------------------------------------- /PerformanceTestOrmLite/lib/ormlite-core-4.34-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/PerformanceTestOrmLite/lib/ormlite-core-4.34-SNAPSHOT.jar -------------------------------------------------------------------------------- /DaoExample/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | greenDAO Note Example 4 | 5 | -------------------------------------------------------------------------------- /PerformanceTestOrmLite/lib/ormlite-android-4.34-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/PerformanceTestOrmLite/lib/ormlite-android-4.34-SNAPSHOT.jar -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/query/QueryBuilderOrderTest.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/path/greenDAO/HEAD/DaoTest/src/de/greenrobot/daotest/query/QueryBuilderOrderTest.java -------------------------------------------------------------------------------- /DaoCore/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jan 31 13:05:10 PST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /DaoGenerator/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jan 31 13:03:24 PST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip 7 | -------------------------------------------------------------------------------- /DaoCore/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DaoTest/assets/minimal-entity.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE MINIMAL_ENTITY (_id INTEGER PRIMARY KEY); 2 | INSERT INTO MINIMAL_ENTITY VALUES (1); 3 | INSERT INTO MINIMAL_ENTITY 4 | VALUES (2); 5 | INSERT INTO MINIMAL_ENTITY VALUES (3) ; 6 | INSERT INTO MINIMAL_ENTITY VALUES (4); 7 | INSERT INTO MINIMAL_ENTITY VALUES (5) ; 8 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/annotations/SerializedField.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.dao.annotations; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | /** 7 | * add this annotation to a field that will be serialized into db 8 | */ 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface SerializedField { 11 | } 12 | -------------------------------------------------------------------------------- /DaoCore/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DaoExample/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-4 12 | -------------------------------------------------------------------------------- /PerformanceTestOrmLite/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-4 12 | -------------------------------------------------------------------------------- /DaoCore/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | android.library=true 11 | # Project target. 12 | target=android-4 13 | -------------------------------------------------------------------------------- /DaoTest/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /DaoTest/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | android.library.reference.1=../DaoCore 11 | # Project target. 12 | target=android-4 13 | -------------------------------------------------------------------------------- /DaoGenerator/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DaoGenerator 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /DaoExampleGenerator/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DaoExampleGenerator 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /DaoExample/src-gen/de/greenrobot/daoexample/Customer.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daoexample; 2 | 3 | 4 | 5 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 6 | /** 7 | * Entity mapped to table CUSTOMER. 8 | */ 9 | public class Customer extends CustomerBase { 10 | public Customer() { 11 | } 12 | 13 | public Customer(Long id) { 14 | super(id); 15 | } 16 | 17 | public Customer(Long id, String name) { 18 | super(id, name); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /PerformanceTestOrmLite/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /PerformanceTestOrmLite/src/de/greenrobot/performance/ormlite/MinimalEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.performance.ormlite; 2 | 3 | import com.j256.ormlite.field.DatabaseField; 4 | import com.j256.ormlite.table.DatabaseTable; 5 | 6 | @DatabaseTable(tableName = "MINIMAL_ENTITY") 7 | public class MinimalEntity { 8 | 9 | @DatabaseField(id = true, columnName="_id") 10 | private Long id; 11 | 12 | public Long getId() { 13 | return id; 14 | } 15 | 16 | public void setId(Long id) { 17 | this.id = id; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /PerformanceTestOrmLite/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /DaoExample/src-gen/de/greenrobot/daoexample/Order.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daoexample; 2 | 3 | 4 | 5 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 6 | /** 7 | * Entity mapped to table ORDERS. 8 | */ 9 | public class Order extends OrderBase { 10 | public Order() { 11 | } 12 | 13 | public Order(Long id) { 14 | super(id); 15 | } 16 | 17 | public Order(Long id, java.util.Date date, long customerId, byte[] serializedCustomer) { 18 | super(id, date, customerId, serializedCustomer); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /DaoTest/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /DaoGenerator/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest/AutoincrementEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 4 | /** 5 | * Entity mapped to table AUTOINCREMENT_ENTITY. 6 | */ 7 | public class AutoincrementEntity { 8 | 9 | private Long id; 10 | 11 | public AutoincrementEntity() { 12 | } 13 | 14 | public AutoincrementEntity(Long id) { 15 | this.id = id; 16 | } 17 | 18 | public Long getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Long id) { 23 | this.id = id; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /DaoExampleGenerator/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /DaoCore/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Sat Jan 28 16:28:19 CET 2012 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.6 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.6 13 | -------------------------------------------------------------------------------- /DaoExample/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Sat Jan 28 16:28:37 CET 2012 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.6 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.6 13 | -------------------------------------------------------------------------------- /DaoTest/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Sat Jan 28 16:28:53 CET 2012 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.6 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.6 13 | -------------------------------------------------------------------------------- /DaoGenerator/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Fri Jul 22 21:20:49 CEST 2011 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.6 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.6 13 | -------------------------------------------------------------------------------- /DaoExampleGenerator/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Wed Aug 03 11:42:59 CEST 2011 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.6 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.6 13 | -------------------------------------------------------------------------------- /DaoExample/src-gen/de/greenrobot/daoexample/Note.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daoexample; 2 | 3 | 4 | 5 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 6 | /** 7 | * Entity mapped to table NOTE. 8 | */ 9 | @Test 10 | @Test2( singleValueeee ) 11 | @Test3( key2 = "value2", key1 = 5 ) 12 | @Test4( key2 = "value2", key1 = null ) 13 | public class Note extends NoteBase { 14 | public Note() { 15 | } 16 | 17 | public Note(Long id) { 18 | super(id); 19 | } 20 | 21 | public Note(Long id, String text, String comment, java.util.Date date, Integer __gender, java.util.List userIds) { 22 | super(id, text, comment, date, __gender, userIds); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /DaoExample/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /DaoGenerator/src-template/annotation.ftl: -------------------------------------------------------------------------------- 1 | <#macro print_annotation annotation prefix> 2 | ${prefix}@${annotation.name}<#rt> 3 | <@compress single_line=true> 4 | <#if annotation.parameters?has_content> 5 | ( 6 | <#assign keys = annotation.parameters?keys> 7 | <#list keys as key> 8 | <#if key != annotation_no_name> 9 | ${key} = 10 | 11 | ${annotation.parameters[key]}<#t> 12 | <#if key_has_next>,<#t> 13 | 14 | ) 15 | 16 | 17 | 18 | 19 | <#macro print_annotations annotations prefix> 20 | <#list annotations as annotation> 21 | <@print_annotation annotation, prefix/> 22 | 23 | 24 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/IdentityScopeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package de.greenrobot.dao; 17 | 18 | public enum IdentityScopeType { 19 | Session, None 20 | } 21 | -------------------------------------------------------------------------------- /DaoCore/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /DaoExample/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest2/to1_specialentity/ToOneTarget2.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest2.to1_specialentity; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, EDIT ONLY INSIDE THE "KEEP"-SECTIONS 4 | 5 | // KEEP INCLUDES - put your custom includes here 6 | // KEEP INCLUDES END 7 | /** 8 | * Entity mapped to table TO_ONE_TARGET2. 9 | */ 10 | public class ToOneTarget2 { 11 | 12 | private Long id; 13 | 14 | // KEEP FIELDS - put your custom fields here 15 | // KEEP FIELDS END 16 | 17 | public ToOneTarget2() { 18 | } 19 | 20 | public ToOneTarget2(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Long id) { 29 | this.id = id; 30 | } 31 | 32 | // KEEP METHODS - put your custom methods here 33 | // KEEP METHODS END 34 | 35 | } 36 | -------------------------------------------------------------------------------- /DaoGenerator/src-template/serialize-helper.ftl: -------------------------------------------------------------------------------- 1 | <#include "*/annotation.ftl"> 2 | <#macro print_serialization_stub stub> 3 | <@print_annotations stub.getterAnnotations, " "/> 4 | public ${stub.className} get${stub.propertyName?cap_first}() { 5 | if(${stub.propertyName} == null && ${stub.property.propertyName} != null) { 6 | ${stub.propertyName} = (${stub.className}) DbUtils.deserializeObject(${stub.property.propertyName}, ${stub.genericClassName}.class); 7 | ${stub.property.propertyName} = null; //clear memory, before save, we'll re-serialize anyways if needed 8 | } 9 | return ${stub.propertyName}; 10 | } 11 | 12 | <@print_annotations stub.setterAnnotations, " "/> 13 | public void set${stub.propertyName?cap_first}(${stub.className} ${stub.propertyName}) { 14 | this.${stub.propertyName} = ${stub.propertyName}; 15 | ${stub.property.propertyName} = null; //onBeforeSave will do serialization 16 | } 17 | -------------------------------------------------------------------------------- /DaoTest/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DaoTest 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /DaoExample/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DaoExample 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /PerformanceTestOrmLite/src/de/greenrobot/performance/ormlite/SimpleEntityNotNullHelper.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.performance.ormlite; 2 | 3 | public class SimpleEntityNotNullHelper { 4 | protected static SimpleEntityNotNull createEntity(Long key) { 5 | if (key == null) { 6 | return null; 7 | } 8 | SimpleEntityNotNull entity = new SimpleEntityNotNull(); 9 | entity.setId(key); 10 | entity.setSimpleBoolean(true); 11 | entity.setSimpleByte(Byte.MAX_VALUE); 12 | entity.setSimpleShort(Short.MAX_VALUE); 13 | entity.setSimpleInt(Integer.MAX_VALUE); 14 | entity.setSimpleLong(Long.MAX_VALUE); 15 | entity.setSimpleFloat(Float.MAX_VALUE); 16 | entity.setSimpleDouble(Double.MAX_VALUE); 17 | entity.setSimpleString("greenrobot greenDAO"); 18 | byte[] bytes = { 42, -17, 23, 0, 127, -128 }; 19 | entity.setSimpleByteArray(bytes); 20 | return entity; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /PerformanceTestOrmLite/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PerformanceTestOrmLite 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest/StringKeyValueEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 4 | /** 5 | * Entity mapped to table STRING_KEY_VALUE_ENTITY. 6 | */ 7 | public class StringKeyValueEntity { 8 | 9 | private String key; 10 | private String value; 11 | 12 | public StringKeyValueEntity() { 13 | } 14 | 15 | public StringKeyValueEntity(String key) { 16 | this.key = key; 17 | } 18 | 19 | public StringKeyValueEntity(String key, String value) { 20 | this.key = key; 21 | this.value = value; 22 | } 23 | 24 | public String getKey() { 25 | return key; 26 | } 27 | 28 | public void setKey(String key) { 29 | this.key = key; 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | public void setValue(String value) { 37 | this.value = value; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /DaoGenerator/src-template/enum-helper.ftl: -------------------------------------------------------------------------------- 1 | <#include "*/annotation.ftl"> 2 | <#macro print_enum_stub stub> 3 | <@print_annotations stub.getterAnnotations, " "/> 4 | public ${stub.className} get${stub.propertyName?cap_first}() { 5 | if(${stub.propertyName} == null && ${stub.property.propertyName} != null) { 6 | try { 7 | ${stub.propertyName} = ${stub.className}.values()[${stub.property.propertyName}]; 8 | } catch(Throwable t) { 9 | //silent fail 10 | } 11 | } 12 | return ${stub.propertyName}; 13 | } 14 | 15 | <@print_annotations stub.setterAnnotations, " "/> 16 | public void set${stub.propertyName?cap_first}(${stub.className} ${stub.propertyName}) { 17 | this.${stub.propertyName} = ${stub.propertyName}; 18 | if( this.${stub.propertyName} == null) { 19 | ${stub.property.propertyName} = null; 20 | } else { 21 | ${stub.property.propertyName} = this.${stub.propertyName}.ordinal(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest2/KeepEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest2; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, EDIT ONLY INSIDE THE "KEEP"-SECTIONS 4 | 5 | // KEEP INCLUDES - put your custom includes here 6 | import android.os.Build; 7 | // KEEP INCLUDES END 8 | /** 9 | * Entity mapped to table KEEP_ENTITY. 10 | */ 11 | public class KeepEntity { 12 | 13 | private Long id; 14 | 15 | // KEEP FIELDS - put your custom fields here 16 | String extra = Build.VERSION.SDK; 17 | // KEEP FIELDS END 18 | 19 | public KeepEntity() { 20 | } 21 | 22 | public KeepEntity(Long id) { 23 | this.id = id; 24 | } 25 | 26 | public Long getId() { 27 | return id; 28 | } 29 | 30 | public void setId(Long id) { 31 | this.id = id; 32 | } 33 | 34 | // KEEP METHODS - put your custom methods here 35 | @Override 36 | public String toString() { 37 | return "KeepEntity ID=42 (extra=" + extra + ")"; 38 | } 39 | // KEEP METHODS END 40 | 41 | } 42 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/SqliteMasterTest.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest.entity; 2 | 3 | import java.util.List; 4 | 5 | import de.greenrobot.dao.DaoLog; 6 | import de.greenrobot.dao.test.AbstractDaoTest; 7 | import de.greenrobot.daotest.SqliteMaster; 8 | import de.greenrobot.daotest.SqliteMasterDao; 9 | import de.greenrobot.daotest.SqliteMasterDao.Properties; 10 | 11 | public class SqliteMasterTest extends AbstractDaoTest { 12 | 13 | public SqliteMasterTest() { 14 | super(SqliteMasterDao.class); 15 | } 16 | 17 | public void testLoadAll() { 18 | List all = dao.loadAll(); 19 | for (SqliteMaster meta : all) { 20 | DaoLog.v(meta.toString()); 21 | } 22 | } 23 | 24 | public void testQueryRaw() { 25 | List tables = dao.queryRaw("WHERE " + Properties.Type.columnName + "=?", "table"); 26 | for (SqliteMaster table : tables) { 27 | DaoLog.v(table.toString()); 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest/ExtendsImplementsEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 4 | /** 5 | * Entity mapped to table EXTENDS_IMPLEMENTS_ENTITY. 6 | */ 7 | public class ExtendsImplementsEntity extends TestSuperclass implements TestInterface, java.io.Serializable { 8 | 9 | private Long id; 10 | private String text; 11 | 12 | public ExtendsImplementsEntity() { 13 | } 14 | 15 | public ExtendsImplementsEntity(Long id) { 16 | this.id = id; 17 | } 18 | 19 | public ExtendsImplementsEntity(Long id, String text) { 20 | this.id = id; 21 | this.text = text; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public String getText() { 33 | return text; 34 | } 35 | 36 | public void setText(String text) { 37 | this.text = text; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /DaoExample/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 20 | 26 | 27 | 31 | 32 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/StringKeyValueEntityTest.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest.entity; 2 | 3 | import junit.framework.Assert; 4 | import de.greenrobot.dao.test.AbstractDaoTestStringPk; 5 | import de.greenrobot.daotest.StringKeyValueEntity; 6 | import de.greenrobot.daotest.StringKeyValueEntityDao; 7 | 8 | public class StringKeyValueEntityTest extends AbstractDaoTestStringPk { 9 | 10 | public StringKeyValueEntityTest() { 11 | super(StringKeyValueEntityDao.class); 12 | } 13 | 14 | @Override 15 | protected StringKeyValueEntity createEntity(String key) { 16 | StringKeyValueEntity entity = new StringKeyValueEntity(); 17 | entity.setKey(key); 18 | return entity; 19 | } 20 | 21 | public void testInsertWithoutPK() { 22 | StringKeyValueEntity entity = createEntity(null); 23 | try { 24 | dao.insert(entity); 25 | Assert.fail("Insert without pre-set PK succeeded"); 26 | } catch (Exception e) { 27 | // Expected 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/CountQuery.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.dao; 2 | 3 | import java.util.Collection; 4 | 5 | import android.database.Cursor; 6 | 7 | public class CountQuery extends AbstractQuery { 8 | 9 | protected CountQuery(AbstractDao dao, String sql, Collection valueList) { 10 | super(dao, sql, valueList); 11 | } 12 | 13 | /** Returns the count (number of results matching the query). Uses SELECT COUNT (*) sematics. */ 14 | public long count() { 15 | Cursor cursor = dao.db.rawQuery(sql, parameters); 16 | try { 17 | if (!cursor.moveToNext()) { 18 | throw new DaoException("No result for count"); 19 | } else if (!cursor.isLast()) { 20 | throw new DaoException("Unexpected row count: " + cursor.getCount()); 21 | } else if (cursor.getColumnCount() != 1) { 22 | throw new DaoException("Unexpected column count: " + cursor.getColumnCount()); 23 | } 24 | return cursor.getLong(0); 25 | } finally { 26 | cursor.close(); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/CloseableListIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package de.greenrobot.dao; 17 | 18 | import java.io.Closeable; 19 | import java.util.ListIterator; 20 | 21 | /** 22 | * A list iterator that needs to be closed (or the associated list) to free underlying resources like a database cursor. 23 | * Typically used with LazyList. 24 | * 25 | * @author Markus 26 | * 27 | * @param 28 | */ 29 | public interface CloseableListIterator extends ListIterator, Closeable { 30 | 31 | } -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest2/ToManyTarget2.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest2; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, EDIT ONLY INSIDE THE "KEEP"-SECTIONS 4 | 5 | // KEEP INCLUDES - put your custom includes here 6 | // KEEP INCLUDES END 7 | /** 8 | * Entity mapped to table TO_MANY_TARGET2. 9 | */ 10 | public class ToManyTarget2 { 11 | 12 | private Long id; 13 | private Long fkId; 14 | 15 | // KEEP FIELDS - put your custom fields here 16 | // KEEP FIELDS END 17 | 18 | public ToManyTarget2() { 19 | } 20 | 21 | public ToManyTarget2(Long id) { 22 | this.id = id; 23 | } 24 | 25 | public ToManyTarget2(Long id, Long fkId) { 26 | this.id = id; 27 | this.fkId = fkId; 28 | } 29 | 30 | public Long getId() { 31 | return id; 32 | } 33 | 34 | public void setId(Long id) { 35 | this.id = id; 36 | } 37 | 38 | public Long getFkId() { 39 | return fkId; 40 | } 41 | 42 | public void setFkId(Long fkId) { 43 | this.fkId = fkId; 44 | } 45 | 46 | // KEEP METHODS - put your custom methods here 47 | // KEEP METHODS END 48 | 49 | } 50 | -------------------------------------------------------------------------------- /DaoGenerator/src/de/greenrobot/daogenerator/PropertyType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daogenerator; 19 | 20 | /** 21 | * Currently available types for properties. 22 | * 23 | * @author Markus 24 | */ 25 | public enum PropertyType { 26 | Byte, Short, Int, Long, Boolean, Float, Double, String, ByteArray, Date, StringList, Enum, Class 27 | } 28 | -------------------------------------------------------------------------------- /DaoCore/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DaoCore 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder 30 | 31 | 32 | 33 | 34 | 35 | com.android.ide.eclipse.adt.AndroidNature 36 | org.eclipse.jdt.core.javanature 37 | edu.umd.cs.findbugs.plugin.eclipse.findbugsNature 38 | 39 | 40 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/ExtendsImplementsEntityTest.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | import de.greenrobot.dao.test.AbstractDaoTestLongPk; 6 | import de.greenrobot.daotest.ExtendsImplementsEntity; 7 | import de.greenrobot.daotest.ExtendsImplementsEntityDao; 8 | import de.greenrobot.daotest.TestInterface; 9 | import de.greenrobot.daotest.TestSuperclass; 10 | 11 | public class ExtendsImplementsEntityTest extends 12 | AbstractDaoTestLongPk { 13 | 14 | public ExtendsImplementsEntityTest() { 15 | super(ExtendsImplementsEntityDao.class); 16 | } 17 | 18 | @Override 19 | protected ExtendsImplementsEntity createEntity(Long key) { 20 | ExtendsImplementsEntity entity = new ExtendsImplementsEntity(); 21 | entity.setId(key); 22 | return entity; 23 | } 24 | 25 | public void testInheritance() { 26 | ExtendsImplementsEntity entity = createEntityWithRandomPk(); 27 | assertTrue(entity instanceof TestSuperclass); 28 | assertTrue(entity instanceof TestInterface); 29 | assertTrue(entity instanceof Serializable); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /DaoGenerator/.freemarker-ide.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /DaoExample/src-test/de/greenrobot/daoexample/NoteTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package de.greenrobot.daoexample; 17 | 18 | import de.greenrobot.dao.test.AbstractDaoTestLongPk; 19 | 20 | public class NoteTest extends AbstractDaoTestLongPk { 21 | 22 | public NoteTest() { 23 | super(NoteDao.class); 24 | } 25 | 26 | @Override 27 | protected Note createEntity(Long key) { 28 | Note entity = new Note(); 29 | entity.setId(key); 30 | entity.setText("green note"); // Has to be set as it is "not null" 31 | return entity; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /DaoCore/mybuild.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | greenDAO API]]> 29 | 30 | Copyright © 2011-2012 greenrobot.de. All Rights Reserved.]]> 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/Command.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.greenrobot.dao; 18 | 19 | /** 20 | * Can be queued (future work). 21 | * 22 | * @author Markus 23 | */ 24 | public class Command { 25 | public static enum CommandType { 26 | Insert, InsertInTx, AndSoOn 27 | } 28 | 29 | public CommandType type; 30 | public AbstractDao dao; 31 | public Object data; 32 | 33 | public Command(CommandType type, AbstractDao dao, Object data) { 34 | this.type = type; 35 | this.dao = dao; 36 | this.data = data; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /DaoExample/proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembernames class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembernames class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers enum * { 30 | public static **[] values(); 31 | public static ** valueOf(java.lang.String); 32 | } 33 | 34 | -keep class * implements android.os.Parcelable { 35 | public static final android.os.Parcelable$Creator *; 36 | } 37 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/StandardApplicationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.greenrobot.daotest; 18 | 19 | import android.app.Application; 20 | import android.test.ApplicationTestCase; 21 | 22 | /** 23 | * Base class for testing with a standard Application class. 24 | * 25 | * @author Markus 26 | * 27 | */ 28 | public abstract class StandardApplicationTest extends ApplicationTestCase { 29 | 30 | public StandardApplicationTest() { 31 | super(Application.class); 32 | } 33 | 34 | @Override 35 | protected void setUp() { 36 | createApplication(); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /DaoGenerator/build.gradle: -------------------------------------------------------------------------------- 1 | task wrapper(type: Wrapper) { 2 | gradleVersion = '1.10' 3 | } 4 | 5 | 6 | buildscript { 7 | repositories { 8 | mavenLocal() 9 | mavenCentral() 10 | maven { url project.ext["pathMaven.repo.snapshots"] } 11 | maven { url project.ext["pathMaven.repo.releases"] } 12 | } 13 | 14 | dependencies { 15 | classpath 'com.android.tools.build:gradle:0.8.+' 16 | classpath 'com.path.android.build:gradle:1.3.+' 17 | } 18 | } 19 | 20 | apply plugin: 'java' 21 | apply plugin: 'pathmaven' 22 | 23 | pathmaven { 24 | groupId "de.greenrobot.dao" 25 | artifactId "generator-path" 26 | version "1.4" 27 | } 28 | 29 | repositories { 30 | maven { url 'http://repo1.maven.org/maven2' } 31 | } 32 | 33 | configurations { 34 | archives { 35 | extendsFrom configurations.default 36 | } 37 | } 38 | 39 | sourceSets { 40 | main { 41 | java { 42 | srcDirs 'src' 43 | } 44 | resources { 45 | srcDir 'src-template' 46 | } 47 | } 48 | } 49 | 50 | dependencies { 51 | compile 'org.freemarker:freemarker:2.3.18' 52 | } 53 | 54 | // task libraryJar(type: Jar) { 55 | // from sourceSets.main.output 56 | // baseName "generator" 57 | // } 58 | // 59 | // artifacts.add('archives', tasks["libraryJar"]); 60 | -------------------------------------------------------------------------------- /DaoCore/proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembers class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembers class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers class * extends android.app.Activity { 30 | public void *(android.view.View); 31 | } 32 | 33 | -keepclassmembers enum * { 34 | public static **[] values(); 35 | public static ** valueOf(java.lang.String); 36 | } 37 | 38 | -keep class * implements android.os.Parcelable { 39 | public static final android.os.Parcelable$Creator *; 40 | } 41 | -------------------------------------------------------------------------------- /DaoTest/proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembers class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembers class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers class * extends android.app.Activity { 30 | public void *(android.view.View); 31 | } 32 | 33 | -keepclassmembers enum * { 34 | public static **[] values(); 35 | public static ** valueOf(java.lang.String); 36 | } 37 | 38 | -keep class * implements android.os.Parcelable { 39 | public static final android.os.Parcelable$Creator *; 40 | } 41 | -------------------------------------------------------------------------------- /PerformanceTestOrmLite/proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembers class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembers class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers class * extends android.app.Activity { 30 | public void *(android.view.View); 31 | } 32 | 33 | -keepclassmembers enum * { 34 | public static **[] values(); 35 | public static ** valueOf(java.lang.String); 36 | } 37 | 38 | -keep class * implements android.os.Parcelable { 39 | public static final android.os.Parcelable$Creator *; 40 | } 41 | -------------------------------------------------------------------------------- /DaoGenerator/src/de/greenrobot/daogenerator/QueryParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daogenerator; 19 | 20 | /** NOT IMPLEMENTED YET. Check back later. */ 21 | public class QueryParam { 22 | private Property column; 23 | private String operator; 24 | 25 | public QueryParam(Property column, String operator) { 26 | this.column = column; 27 | this.operator = operator; 28 | } 29 | 30 | public Property getColumn() { 31 | return column; 32 | } 33 | 34 | public String getOperator() { 35 | return operator; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/performance/PerformanceTestNotNullIdentityScope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.performance; 19 | 20 | import de.greenrobot.dao.IdentityScopeLong; 21 | import de.greenrobot.daotest.SimpleEntityNotNull; 22 | 23 | public class PerformanceTestNotNullIdentityScope extends PerformanceTestNotNull { 24 | 25 | @Override 26 | protected void setUp() { 27 | IdentityScopeLong identityScope = new IdentityScopeLong< SimpleEntityNotNull>(); 28 | setIdentityScopeBeforeSetUp(identityScope); 29 | super.setUp(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest/DateEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 4 | /** 5 | * Entity mapped to table DATE_ENTITY. 6 | */ 7 | public class DateEntity { 8 | 9 | private Long id; 10 | private java.util.Date date; 11 | /** Not-null value. */ 12 | private java.util.Date dateNotNull; 13 | 14 | public DateEntity() { 15 | } 16 | 17 | public DateEntity(Long id) { 18 | this.id = id; 19 | } 20 | 21 | public DateEntity(Long id, java.util.Date date, java.util.Date dateNotNull) { 22 | this.id = id; 23 | this.date = date; 24 | this.dateNotNull = dateNotNull; 25 | } 26 | 27 | public Long getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Long id) { 32 | this.id = id; 33 | } 34 | 35 | public java.util.Date getDate() { 36 | return date; 37 | } 38 | 39 | public void setDate(java.util.Date date) { 40 | this.date = date; 41 | } 42 | 43 | /** Not-null value. */ 44 | public java.util.Date getDateNotNull() { 45 | return dateNotNull; 46 | } 47 | 48 | /** Not-null value; ensure this value is available before it is saved to the database. */ 49 | public void setDateNotNull(java.util.Date dateNotNull) { 50 | this.dateNotNull = dateNotNull; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /DaoGenerator/src/de/greenrobot/daogenerator/Index.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daogenerator; 19 | 20 | 21 | public class Index extends PropertyOrderList { 22 | private String name; 23 | private boolean unique; 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public Index setName(String name) { 30 | this.name = name; 31 | return this; 32 | } 33 | 34 | public Index makeUnique() { 35 | unique = true; 36 | return this; 37 | } 38 | 39 | public boolean isUnique() { 40 | return unique; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/AutoincrementEntityTest.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest.entity; 2 | 3 | import android.app.Application; 4 | import de.greenrobot.dao.test.AbstractDaoSessionTest; 5 | import de.greenrobot.daotest.AutoincrementEntity; 6 | import de.greenrobot.daotest.DaoMaster; 7 | import de.greenrobot.daotest.DaoSession; 8 | import de.greenrobot.daotest.SimpleEntity; 9 | 10 | public class AutoincrementEntityTest extends AbstractDaoSessionTest { 11 | 12 | public AutoincrementEntityTest() { 13 | super(DaoMaster.class); 14 | } 15 | 16 | public void testAutoincrement() { 17 | AutoincrementEntity entity = new AutoincrementEntity(); 18 | daoSession.insert(entity); 19 | Long id1 = entity.getId(); 20 | assertNotNull(id1); 21 | daoSession.delete(entity); 22 | 23 | AutoincrementEntity entity2 = new AutoincrementEntity(); 24 | daoSession.insert(entity2); 25 | assertEquals(id1 + 1, (long) entity2.getId()); 26 | } 27 | 28 | public void testNoAutoincrement() { 29 | SimpleEntity entity = new SimpleEntity(); 30 | daoSession.insert(entity); 31 | Long id1 = entity.getId(); 32 | assertNotNull(id1); 33 | daoSession.delete(entity); 34 | 35 | SimpleEntity entity2 = new SimpleEntity(); 36 | daoSession.insert(entity2); 37 | assertEquals(id1, entity2.getId()); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/IdentityScope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package de.greenrobot.dao; 17 | 18 | /** 19 | * Common interface for a identity scopes needed internally by greenDAO. Identity scopes let greenDAO re-use Java 20 | * objects. 21 | * 22 | * @author Markus 23 | * 24 | * @param Key 25 | * @param 26 | * Entity 27 | */ 28 | public interface IdentityScope { 29 | 30 | T get(K key); 31 | 32 | void put(K key, T entity); 33 | 34 | T getNoLock(K key); 35 | 36 | void putNoLock(K key, T entity); 37 | 38 | boolean detach(K key, T entity); 39 | 40 | void remove(K key); 41 | 42 | void remove(Iterable key); 43 | 44 | void clear(); 45 | 46 | void lock(); 47 | 48 | void unlock(); 49 | 50 | void reserveRoom(int count); 51 | 52 | } -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/AbcdefEntityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.entity; 19 | 20 | import de.greenrobot.dao.test.AbstractDaoTestLongPk; 21 | import de.greenrobot.daotest.AbcdefEntity; 22 | import de.greenrobot.daotest.AbcdefEntityDao; 23 | 24 | public class AbcdefEntityTest extends AbstractDaoTestLongPk { 25 | 26 | public AbcdefEntityTest() { 27 | super(AbcdefEntityDao.class); 28 | } 29 | 30 | @Override 31 | protected AbcdefEntity createEntity(Long key) { 32 | AbcdefEntity entity = new AbcdefEntity(); 33 | entity.setId(key); 34 | return entity; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/DbUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest; 19 | 20 | import java.io.IOException; 21 | 22 | import android.database.Cursor; 23 | import de.greenrobot.dao.DbUtils; 24 | import de.greenrobot.dao.test.DbTest; 25 | 26 | public class DbUtilsTest extends DbTest { 27 | 28 | public void testExecuteSqlScript() throws IOException { 29 | DbUtils.executeSqlScript(getApplication(), db, "minimal-entity.sql"); 30 | Cursor cursor = db.rawQuery("SELECT count(*) from MINIMAL_ENTITY", null); 31 | try { 32 | cursor.moveToFirst(); 33 | assertEquals(5, cursor.getInt(0)); 34 | } finally { 35 | cursor.close(); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/SpecialNamesEntityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.entity; 19 | 20 | import de.greenrobot.dao.test.AbstractDaoTestLongPk; 21 | import de.greenrobot.daotest.SpecialNamesEntity; 22 | import de.greenrobot.daotest.SpecialNamesEntityDao; 23 | 24 | public class SpecialNamesEntityTest extends AbstractDaoTestLongPk { 25 | 26 | public SpecialNamesEntityTest() { 27 | super(SpecialNamesEntityDao.class); 28 | } 29 | 30 | @Override 31 | protected SpecialNamesEntity createEntity(Long key) { 32 | SpecialNamesEntity entity = new SpecialNamesEntity(); 33 | entity.setId(key); 34 | return entity; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/ToManyTargetEntityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.entity; 19 | 20 | import de.greenrobot.dao.test.AbstractDaoTestLongPk; 21 | import de.greenrobot.daotest.ToManyTargetEntity; 22 | import de.greenrobot.daotest.ToManyTargetEntityDao; 23 | 24 | public class ToManyTargetEntityTest extends AbstractDaoTestLongPk { 25 | 26 | public ToManyTargetEntityTest() { 27 | super(ToManyTargetEntityDao.class); 28 | } 29 | 30 | @Override 31 | protected ToManyTargetEntity createEntity(Long key) { 32 | ToManyTargetEntity entity = new ToManyTargetEntity(); 33 | entity.setId(key); 34 | return entity; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/performance/PerformanceTestNotNull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.performance; 19 | 20 | import de.greenrobot.daotest.SimpleEntityNotNull; 21 | import de.greenrobot.daotest.SimpleEntityNotNullDao; 22 | import de.greenrobot.daotest.entity.SimpleEntityNotNullHelper; 23 | 24 | public class PerformanceTestNotNull extends PerformanceTest { 25 | 26 | static long sequence; 27 | 28 | public PerformanceTestNotNull() { 29 | super(SimpleEntityNotNullDao.class); 30 | } 31 | 32 | @Override 33 | protected SimpleEntityNotNull createEntity() { 34 | return SimpleEntityNotNullHelper.createEntity(sequence++); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /PerformanceTestOrmLite/src/de/greenrobot/performance/ormlite/DbHelper.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.performance.ormlite; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteOpenHelper; 6 | 7 | public class DbHelper extends SQLiteOpenHelper { 8 | 9 | public DbHelper(Context context, String name) { 10 | super(context, name, null, 1); 11 | } 12 | 13 | @Override 14 | public void onCreate(SQLiteDatabase db) { 15 | String sql = "CREATE TABLE SIMPLE_ENTITY_NOT_NULL (" + // 16 | "_id INTEGER PRIMARY KEY NOT NULL ," + // 0 17 | "SIMPLE_BOOLEAN INTEGER NOT NULL ," + // 1 18 | "SIMPLE_BYTE INTEGER NOT NULL ," + // 2 19 | "SIMPLE_SHORT INTEGER NOT NULL ," + // 3 20 | "SIMPLE_INT INTEGER NOT NULL ," + // 4 21 | "SIMPLE_LONG INTEGER NOT NULL ," + // 5 22 | "SIMPLE_FLOAT REAL NOT NULL ," + // 6 23 | "SIMPLE_DOUBLE REAL NOT NULL ," + // 7 24 | "SIMPLE_STRING TEXT NOT NULL ," + // 8 25 | "SIMPLE_BYTE_ARRAY BLOB NOT NULL )"; // 9 26 | db.execSQL(sql); 27 | 28 | String sql2 = "CREATE TABLE MINIMAL_ENTITY (_id INTEGER PRIMARY KEY)"; 29 | db.execSQL(sql2); 30 | } 31 | 32 | @Override 33 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 34 | db.execSQL("DROP TABLE IF EXISTS SIMPLE_ENTITY_NOT_NULL"); 35 | db.execSQL("DROP TABLE IF EXISTS MINIMAL_ENTITY"); 36 | onCreate(db); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest/ToManyTargetEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 4 | /** 5 | * Entity mapped to table TO_MANY_TARGET_ENTITY. 6 | */ 7 | public class ToManyTargetEntity { 8 | 9 | private Long toManyId; 10 | private Long toManyIdDesc; 11 | private Long id; 12 | private String targetJoinProperty; 13 | 14 | public ToManyTargetEntity() { 15 | } 16 | 17 | public ToManyTargetEntity(Long id) { 18 | this.id = id; 19 | } 20 | 21 | public ToManyTargetEntity(Long toManyId, Long toManyIdDesc, Long id, String targetJoinProperty) { 22 | this.toManyId = toManyId; 23 | this.toManyIdDesc = toManyIdDesc; 24 | this.id = id; 25 | this.targetJoinProperty = targetJoinProperty; 26 | } 27 | 28 | public Long getToManyId() { 29 | return toManyId; 30 | } 31 | 32 | public void setToManyId(Long toManyId) { 33 | this.toManyId = toManyId; 34 | } 35 | 36 | public Long getToManyIdDesc() { 37 | return toManyIdDesc; 38 | } 39 | 40 | public void setToManyIdDesc(Long toManyIdDesc) { 41 | this.toManyIdDesc = toManyIdDesc; 42 | } 43 | 44 | public Long getId() { 45 | return id; 46 | } 47 | 48 | public void setId(Long id) { 49 | this.id = id; 50 | } 51 | 52 | public String getTargetJoinProperty() { 53 | return targetJoinProperty; 54 | } 55 | 56 | public void setTargetJoinProperty(String targetJoinProperty) { 57 | this.targetJoinProperty = targetJoinProperty; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/test/AbstractDaoTestStringPk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package de.greenrobot.dao.test; 17 | 18 | import de.greenrobot.dao.AbstractDao; 19 | 20 | /** 21 | * Base class for DAOs having a String as a PK. 22 | * 23 | * @author Markus 24 | * 25 | * @param 26 | * DAO class 27 | * @param 28 | * Entity type of the DAO 29 | */ 30 | public abstract class AbstractDaoTestStringPk, T> extends 31 | AbstractDaoTestSinglePk { 32 | 33 | public AbstractDaoTestStringPk(Class daoClass) { 34 | super(daoClass); 35 | } 36 | 37 | @Override 38 | protected String createRandomPk() { 39 | int len = 1 + random.nextInt(30); 40 | StringBuilder builder = new StringBuilder(); 41 | for (int i = 0; i < len; i++) { 42 | char c = (char) ('a' + random.nextInt('z' - 'a')); 43 | builder.append(c); 44 | } 45 | return builder.toString(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/DaoException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package de.greenrobot.dao; 17 | 18 | import android.database.SQLException; 19 | 20 | /** 21 | * Exception thrown when something goes wrong in the DAO/ORM layer. 22 | * 23 | * @author Markus 24 | * 25 | */ 26 | public class DaoException extends SQLException { 27 | 28 | private static final long serialVersionUID = -5877937327907457779L; 29 | 30 | public DaoException() { 31 | } 32 | 33 | public DaoException(String error) { 34 | super(error); 35 | } 36 | 37 | public DaoException(String error, Throwable cause) { 38 | super(error); 39 | safeInitCause(cause); 40 | } 41 | 42 | public DaoException(Throwable th) { 43 | safeInitCause(th); 44 | } 45 | 46 | protected void safeInitCause(Throwable cause) { 47 | try { 48 | initCause(cause); 49 | } catch (Throwable e) { 50 | DaoLog.e("Could not set initial cause", e); 51 | DaoLog.e( "Initial cause is:", cause); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest2/entity/KeepEntityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest2.entity; 19 | 20 | import android.os.Build; 21 | import de.greenrobot.dao.test.AbstractDaoTestLongPk; 22 | import de.greenrobot.daotest2.KeepEntity; 23 | import de.greenrobot.daotest2.dao.KeepEntityDao; 24 | 25 | public class KeepEntityTest extends AbstractDaoTestLongPk { 26 | 27 | public KeepEntityTest() { 28 | super(KeepEntityDao.class); 29 | } 30 | 31 | @Override 32 | protected KeepEntity createEntity(Long key) { 33 | KeepEntity entity = new KeepEntity(); 34 | entity.setId(key); 35 | return entity; 36 | } 37 | 38 | public void testKeepSectionAvailable() { 39 | KeepEntity keepEntity = new KeepEntity(42l); 40 | assertEquals("KeepEntity ID=42 (extra="+Build.VERSION.SDK+")", keepEntity.toString()); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /DaoCore/build.gradle: -------------------------------------------------------------------------------- 1 | task wrapper(type: Wrapper) { 2 | gradleVersion = '2.2.1' 3 | } 4 | 5 | buildscript { 6 | repositories { 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:1.0.+' 12 | } 13 | } 14 | 15 | apply plugin: 'android-library' 16 | apply plugin: 'maven' 17 | 18 | 19 | repositories { 20 | maven { url 'http://repo1.maven.org/maven2' } 21 | } 22 | 23 | android { 24 | compileSdkVersion 18 25 | buildToolsVersion "21.1.1" 26 | 27 | defaultConfig { 28 | minSdkVersion 4 29 | } 30 | sourceSets { 31 | main { 32 | manifest.srcFile 'AndroidManifest.xml' 33 | java.srcDirs = ['src'] 34 | res.srcDirs = ['res'] 35 | } 36 | } 37 | } 38 | 39 | def deployToProd = hasProperty("pathMaven.deployToProd") && project.ext["pathMaven.deployToProd"].toBoolean() 40 | println "will deploy to prod?" + deployToProd 41 | 42 | uploadArchives { 43 | repositories { 44 | mavenDeployer { 45 | if(deployToProd) { 46 | snapshotRepository(url: project.ext["pathMaven.repo.snapshots"]) { 47 | authentication(userName: project.ext["pathMaven.username"], password: project.ext["pathMaven.password"]); 48 | } 49 | 50 | repository(url: project.ext["pathMaven.repo.releases"]) { 51 | authentication(userName: project.ext["pathMaven.username"], password: project.ext["pathMaven.password"]); 52 | } 53 | } else { 54 | repository(url: mavenLocal().getUrl()) 55 | } 56 | 57 | pom.project { 58 | groupId 'de.greenrobot.dao' 59 | artifactId 'core' 60 | version '1.1.4' 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /DaoGenerator/src/de/greenrobot/daogenerator/Query.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daogenerator; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | /** NOT IMPLEMENTED YET. Check back later. */ 24 | public class Query { 25 | @SuppressWarnings("unused") 26 | private String name; 27 | private List parameters; 28 | @SuppressWarnings("unused") 29 | private boolean distinct; 30 | 31 | public Query(String name) { 32 | this.name = name; 33 | parameters= new ArrayList(); 34 | } 35 | 36 | public QueryParam addEqualsParam(Property column) { 37 | return addParam(column, "="); 38 | } 39 | 40 | public QueryParam addParam(Property column, String operator) { 41 | QueryParam queryParam = new QueryParam(column, operator); 42 | parameters.add(queryParam); 43 | return queryParam; 44 | } 45 | 46 | public void distinct() { 47 | distinct = true; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/SimpleEntityNotNullHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.entity; 19 | 20 | import de.greenrobot.daotest.SimpleEntityNotNull; 21 | 22 | 23 | public class SimpleEntityNotNullHelper { 24 | public static SimpleEntityNotNull createEntity(Long key) { 25 | if (key == null) { 26 | return null; 27 | } 28 | SimpleEntityNotNull entity = new SimpleEntityNotNull(); 29 | entity.setId(key); 30 | entity.setSimpleBoolean(true); 31 | entity.setSimpleByte(Byte.MAX_VALUE); 32 | entity.setSimpleShort(Short.MAX_VALUE); 33 | entity.setSimpleInt(Integer.MAX_VALUE); 34 | entity.setSimpleLong(Long.MAX_VALUE); 35 | entity.setSimpleFloat(Float.MAX_VALUE); 36 | entity.setSimpleDouble(Double.MAX_VALUE); 37 | entity.setSimpleString("greenrobot greenDAO"); 38 | byte[] bytes = { 42, -17, 23, 0, 127, -128 }; 39 | entity.setSimpleByteArray(bytes); 40 | return entity; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /DaoGenerator/src/de/greenrobot/daogenerator/Annotation.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daogenerator; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.regex.Pattern; 6 | 7 | /** 8 | * Model class for an Annotation that can be attached to classses, properties or methods 9 | * @author yigit@path.com 10 | */ 11 | public class Annotation { 12 | private String name; 13 | protected String _package; 14 | private Map parameters = new HashMap(); 15 | public static Pattern QUOTE = Pattern.compile("\""); 16 | 17 | //we use this if Annotation has only 1 parameter 18 | public static final String NO_NAME = "__no_name"; 19 | public static final String NULL = "null"; 20 | 21 | public Annotation(String name, String... params) { 22 | this.name = name; 23 | this.parameters = new HashMap(); 24 | if(params.length > 1 && params.length % 2 != 0) { 25 | throw new RuntimeException("annotation parameters should be key value pairs"); 26 | } 27 | if(params.length == 1) { 28 | this.parameters.put(NO_NAME, params[0] == null ? NULL : params[0]); 29 | } else { 30 | for(int i = 0; i < params.length; i += 2) { 31 | this.parameters.put(params[i], params[i + 1] == null ? NULL : params[i + 1]); 32 | } 33 | } 34 | } 35 | 36 | public String getPackage() { 37 | return _package; 38 | } 39 | 40 | public void setPackage(String _package) { 41 | this._package = _package; 42 | } 43 | 44 | public Annotation(String name) { 45 | this.name = name; 46 | } 47 | 48 | public String getName() { 49 | return name; 50 | } 51 | 52 | public Map getParameters() { 53 | return parameters; 54 | } 55 | 56 | public Annotation withPackage(String _package) { 57 | this._package = _package; 58 | return this; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/IndexTest.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | import java.util.List; 4 | 5 | import junit.framework.Assert; 6 | 7 | import de.greenrobot.dao.DaoLog; 8 | import de.greenrobot.dao.test.AbstractDaoTest; 9 | import de.greenrobot.daotest.SqliteMaster; 10 | import de.greenrobot.daotest.SqliteMasterDao; 11 | import de.greenrobot.daotest.SqliteMasterDao.Properties; 12 | 13 | public class IndexTest extends AbstractDaoTest { 14 | 15 | public IndexTest() { 16 | super(SqliteMasterDao.class); 17 | } 18 | 19 | public void testIndexesCreated() { 20 | Assert.assertEquals(0, getIndexes().size()); 21 | 22 | TestEntityDao.createTable(db, false); 23 | List indexes = getIndexes(); 24 | Assert.assertEquals(2, indexes.size()); 25 | 26 | SqliteMaster index1 = indexes.get(0); 27 | SqliteMaster index2 = indexes.get(1); 28 | Assert.assertEquals(TestEntityDao.TABLENAME, index1.getTableName()); 29 | Assert.assertEquals(TestEntityDao.TABLENAME, index2.getTableName()); 30 | Assert.assertEquals("IDX_TEST_ENTITY_INDEXED_STRING", index1.getName()); 31 | Assert.assertEquals("IDX_TEST_ENTITY_INDEXED_STRING_ASC_UNIQUE", index2.getName()); 32 | 33 | for (SqliteMaster index : indexes) { 34 | DaoLog.v(index.toString()); 35 | } 36 | } 37 | 38 | public void testIndexCreateIfNotExists() { 39 | Assert.assertEquals(0, getIndexes().size()); 40 | TestEntityDao.createTable(db, false); 41 | Assert.assertEquals(2, getIndexes().size()); 42 | TestEntityDao.createTable(db, true); 43 | Assert.assertEquals(2, getIndexes().size()); 44 | } 45 | 46 | private List getIndexes() { 47 | String where = "WHERE " + Properties.Type.columnName + "=? ORDER BY " + Properties.Name.columnName; 48 | List indexes = dao.queryRaw(where, "index"); 49 | return indexes; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest/SqliteMaster.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, EDIT ONLY INSIDE THE "KEEP"-SECTIONS 4 | 5 | // KEEP INCLUDES - put your custom includes here 6 | // KEEP INCLUDES END 7 | /** 8 | * Entity mapped to table SQLITE_MASTER. 9 | */ 10 | public class SqliteMaster { 11 | 12 | private String type; 13 | private String name; 14 | private String tableName; 15 | private Long rootpage; 16 | private String sql; 17 | 18 | // KEEP FIELDS - put your custom fields here 19 | // KEEP FIELDS END 20 | 21 | public SqliteMaster() { 22 | } 23 | 24 | public SqliteMaster(String type, String name, String tableName, Long rootpage, String sql) { 25 | this.type = type; 26 | this.name = name; 27 | this.tableName = tableName; 28 | this.rootpage = rootpage; 29 | this.sql = sql; 30 | } 31 | 32 | public String getType() { 33 | return type; 34 | } 35 | 36 | public void setType(String type) { 37 | this.type = type; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | public String getTableName() { 49 | return tableName; 50 | } 51 | 52 | public void setTableName(String tableName) { 53 | this.tableName = tableName; 54 | } 55 | 56 | public Long getRootpage() { 57 | return rootpage; 58 | } 59 | 60 | public void setRootpage(Long rootpage) { 61 | this.rootpage = rootpage; 62 | } 63 | 64 | public String getSql() { 65 | return sql; 66 | } 67 | 68 | public void setSql(String sql) { 69 | this.sql = sql; 70 | } 71 | 72 | // KEEP METHODS - put your custom methods here 73 | @Override 74 | public String toString() { 75 | return "Type: " + type + ", name: " + name + ", table: " + tableName + ", SQL: " + sql; 76 | } 77 | // KEEP METHODS END 78 | 79 | } 80 | -------------------------------------------------------------------------------- /DaoExample/src-test/de/greenrobot/daoexample/CustomerOrderTest.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daoexample; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import android.app.Application; 7 | import de.greenrobot.dao.test.AbstractDaoSessionTest; 8 | 9 | public class CustomerOrderTest extends AbstractDaoSessionTest { 10 | 11 | public CustomerOrderTest() { 12 | super(DaoMaster.class); 13 | } 14 | 15 | public void testCustomerToOrders() { 16 | Customer customer = new Customer(null, "greenrobot"); 17 | daoSession.insert(customer); 18 | 19 | addOrderToCustomer(customer); 20 | addOrderToCustomer(customer); 21 | 22 | List orders = customer.getOrders(); 23 | assertEquals(2, orders.size()); 24 | } 25 | 26 | public void testOrderToCustomer() { 27 | Customer customer = new Customer(null, "greenrobot"); 28 | daoSession.insert(customer); 29 | 30 | Order order = addOrderToCustomer(customer); 31 | Customer customer2 = order.getCustomer(); 32 | 33 | assertSame(customer, customer2); 34 | } 35 | 36 | public void testUpdateBirectional() { 37 | Customer customer = new Customer(null, "greenrobot"); 38 | daoSession.insert(customer); 39 | 40 | addOrderToCustomer(customer); 41 | List orders = customer.getOrders(); 42 | 43 | Order newOrder = new Order(); 44 | newOrder.setCustomer(customer); 45 | daoSession.insert(newOrder); 46 | orders.add(newOrder); 47 | assertEquals(2, orders.size()); 48 | 49 | customer.resetOrders(); 50 | List orders2 = customer.getOrders(); 51 | assertEquals(orders.size(), orders2.size()); 52 | } 53 | 54 | private Order addOrderToCustomer(Customer customer) { 55 | Date date = new Date(System.currentTimeMillis() - ((long) (Math.random() * 1000 * 60 * 60 * 24 * 365))); 56 | Order order = new Order(null, date, customer.getId()); 57 | daoSession.insert(order); 58 | return order; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/AbstractDaoMaster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.greenrobot.dao; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | import android.database.sqlite.SQLiteDatabase; 23 | 24 | /** 25 | * The master of dao will guide you: start dao sessions with the master. 26 | * 27 | * @author Markus 28 | */ 29 | public abstract class AbstractDaoMaster { 30 | protected final SQLiteDatabase db; 31 | protected final int schemaVersion; 32 | protected final Map>, DaoConfig> daoConfigMap; 33 | 34 | public AbstractDaoMaster(SQLiteDatabase db, int schemaVersion) { 35 | this.db = db; 36 | this.schemaVersion = schemaVersion; 37 | 38 | daoConfigMap = new HashMap>, DaoConfig>(); 39 | } 40 | 41 | protected void registerDaoClass(Class> daoClass) { 42 | DaoConfig daoConfig = new DaoConfig(db, daoClass); 43 | daoConfigMap.put(daoClass, daoConfig); 44 | } 45 | 46 | public int getSchemaVersion() { 47 | return schemaVersion; 48 | } 49 | 50 | /** Gets the SQLiteDatabase for custom database access. Not needed for greenDAO entities. */ 51 | public SQLiteDatabase getDatabase() { 52 | return db; 53 | } 54 | 55 | public abstract AbstractDaoSession newSession(); 56 | 57 | public abstract AbstractDaoSession newSession(IdentityScopeType type); 58 | } 59 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/UnitTestDaoAccess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.greenrobot.dao; 18 | 19 | import java.lang.reflect.Constructor; 20 | 21 | import android.database.Cursor; 22 | import android.database.sqlite.SQLiteDatabase; 23 | 24 | /** Reserved for internal unit tests that want to access some non-public methods. Don't use for anything else. */ 25 | public class UnitTestDaoAccess { 26 | private final AbstractDao dao; 27 | 28 | public UnitTestDaoAccess(SQLiteDatabase db, Class> daoClass, IdentityScope identityScope) 29 | throws Exception { 30 | DaoConfig daoConfig = new DaoConfig(db, daoClass); 31 | daoConfig.setIdentityScope(identityScope); 32 | Constructor> constructor = daoClass.getConstructor(DaoConfig.class); 33 | dao = constructor.newInstance(daoConfig); 34 | } 35 | 36 | public K getKey(T entity) { 37 | return dao.getKey(entity); 38 | } 39 | 40 | public Property[] getProperties() { 41 | return dao.getProperties(); 42 | } 43 | 44 | public boolean isEntityUpdateable() { 45 | return dao.isEntityUpdateable(); 46 | } 47 | 48 | public T readEntity(Cursor cursor, int offset) { 49 | return dao.readEntity(cursor, offset); 50 | } 51 | 52 | public K readKey(Cursor cursor, int offset) { 53 | return dao.readKey(cursor, offset); 54 | } 55 | 56 | public AbstractDao getDao() { 57 | return dao; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/DeleteQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package de.greenrobot.dao; 17 | 18 | import java.util.Collection; 19 | 20 | import android.database.sqlite.SQLiteStatement; 21 | 22 | /** 23 | * A repeatable query for deleting entities.
24 | * New API note: this is more likely to change. 25 | * 26 | * @author Markus 27 | * 28 | * @param 29 | * The enitity class the query will delete from. 30 | */ 31 | public class DeleteQuery extends AbstractQuery { 32 | 33 | private SQLiteStatement compiledStatement; 34 | 35 | public DeleteQuery(AbstractDao dao, String sql, Collection valueList) { 36 | super(dao, sql, valueList); 37 | } 38 | 39 | /** 40 | * Deletes all matching entities without detaching them from the identity scope (aka session/cache). Note that this 41 | * method may lead to stale entity objects in the session cache. Stale entities may be returned when loaded by their 42 | * primary key, but not using queries. 43 | */ 44 | public synchronized void executeDeleteWithoutDetachingEntities() { 45 | if (compiledStatement != null) { 46 | compiledStatement.clearBindings(); 47 | } else { 48 | compiledStatement = dao.db.compileStatement(sql); 49 | } 50 | for (int i = 0; i < parameters.length; i++) { 51 | String value = parameters[i]; 52 | if (value != null) { 53 | compiledStatement.bindString(i + 1, value); 54 | } else { 55 | compiledStatement.bindNull(i + 1); 56 | } 57 | } 58 | compiledStatement.execute(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/AbstractQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package de.greenrobot.dao; 17 | 18 | import java.util.Collection; 19 | 20 | /** 21 | * A repeatable query returning entities. 22 | * 23 | * @author Markus 24 | * 25 | * @param 26 | * The enitity class the query will return results for. 27 | */ 28 | // TODO support long, double, blob types directly 29 | abstract class AbstractQuery { 30 | protected final AbstractDao dao; 31 | protected final String sql; 32 | protected final String[] parameters; 33 | 34 | protected AbstractQuery(AbstractDao dao, String sql, Collection valueList) { 35 | this.dao = dao; 36 | this.sql = sql; 37 | 38 | parameters = new String[valueList.size()]; 39 | int idx = 0; 40 | for (Object object : valueList) { 41 | if (object != null) { 42 | parameters[idx] = object.toString(); 43 | } else { 44 | parameters[idx] = null; 45 | } 46 | idx++; 47 | } 48 | } 49 | 50 | // public void compile() { 51 | // // TODO implement compile 52 | // } 53 | 54 | /** 55 | * Sets the parameter (0 based) using the position in which it was added during building the query. 56 | */ 57 | public void setParameter(int index, Object parameter) { 58 | if (parameter != null) { 59 | parameters[index] = parameter.toString(); 60 | } else { 61 | parameters[index] = null; 62 | } 63 | } 64 | 65 | public String getSql() { 66 | return sql; 67 | } 68 | 69 | public String[] getParameters() { 70 | return parameters; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /DaoGenerator/src/de/greenrobot/daogenerator/EnumProperty.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daogenerator; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class EnumProperty { 7 | protected Property property; 8 | protected String propertyName; 9 | protected String className; 10 | protected List imports = new ArrayList(); 11 | 12 | private List setterAnnotations = new ArrayList(); 13 | private List getterAnnotations = new ArrayList(); 14 | 15 | public EnumProperty(Property property, String propertyName, String className) { 16 | if(property.getPropertyType() != PropertyType.Int) { 17 | throw new RuntimeException("Enum properties can only be constructed on top of int properties"); 18 | } 19 | this.property = property; 20 | this.propertyName = propertyName; 21 | this.className = className; 22 | property.setEnumarated(this); 23 | } 24 | 25 | public Property getProperty() { 26 | return property; 27 | } 28 | 29 | public String getPropertyName() { 30 | return propertyName; 31 | } 32 | 33 | public String getClassName() { 34 | return className; 35 | } 36 | 37 | public EnumProperty constant() { 38 | property.setConstant(true); 39 | return this; 40 | } 41 | 42 | public boolean isConstant() { 43 | return property.isConstant(); 44 | } 45 | 46 | public List getSetterAnnotations() { 47 | return setterAnnotations; 48 | } 49 | 50 | public List getGetterAnnotations() { 51 | return getterAnnotations; 52 | } 53 | 54 | public EnumProperty addSetterAnnotation(Annotation annotation) { 55 | setterAnnotations.add(annotation); 56 | return this; 57 | } 58 | 59 | public EnumProperty addSetterGetterAnnotation(Annotation annotation) { 60 | setterAnnotations.add(annotation); 61 | getterAnnotations.add(annotation); 62 | return this; 63 | } 64 | 65 | public EnumProperty addGetterAnnotation(Annotation annotation) { 66 | getterAnnotations.add(annotation); 67 | return this; 68 | } 69 | 70 | public EnumProperty addImport(String pack) { 71 | this.imports.add(pack); 72 | return this; 73 | } 74 | 75 | public List getImports() { 76 | return imports; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /DaoGenerator/src-template/dao-unit-test.ftl: -------------------------------------------------------------------------------- 1 | <#-- 2 | 3 | Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 4 | 5 | This file is part of greenDAO Generator. 6 | 7 | greenDAO Generator is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | greenDAO Generator is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with greenDAO Generator. If not, see . 18 | 19 | --> 20 | package ${entity.javaPackageTest}; 21 | 22 | <#assign isStringPK = entity.pkProperty?? && entity.pkProperty.propertyType == "String" /> 23 | <#if isStringPK> 24 | import de.greenrobot.dao.test.AbstractDaoTestStringPk; 25 | <#else> 26 | import de.greenrobot.dao.test.AbstractDaoTestLongPk; 27 | 28 | 29 | import ${entity.javaPackage}.${entity.className}; 30 | import ${entity.javaPackageDao}.${entity.classNameDao}; 31 | 32 | public class ${entity.classNameTest} extends <#if 33 | isStringPK>AbstractDaoTestStringPk<${entity.classNameDao}, ${entity.className}><#else>AbstractDaoTestLongPk<${entity.classNameDao}, ${entity.className}> { 34 | 35 | public ${entity.classNameTest}() { 36 | super(${entity.classNameDao}.class); 37 | } 38 | 39 | @Override 40 | protected ${entity.className} createEntity(<#if isStringPK>String<#else>Long key) { 41 | ${entity.className} entity = new ${entity.className}(); 42 | <#if entity.pkProperty??> 43 | entity.set${entity.pkProperty.propertyName?cap_first}(key); 44 | 45 | <#list entity.properties as property> 46 | <#if property.notNull> 47 | entity.set${property.propertyName?cap_first}(); 48 | 49 | 50 | return entity; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest/AnActiveEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | import de.greenrobot.daotest.DaoSession; 4 | import de.greenrobot.dao.DaoException; 5 | 6 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 7 | /** 8 | * Entity mapped to table AN_ACTIVE_ENTITY. 9 | */ 10 | public class AnActiveEntity { 11 | 12 | private Long id; 13 | private String text; 14 | 15 | /** Used to resolve relations */ 16 | private transient DaoSession daoSession; 17 | 18 | /** Used for active entity operations. */ 19 | private transient AnActiveEntityDao myDao; 20 | 21 | 22 | public AnActiveEntity() { 23 | } 24 | 25 | public AnActiveEntity(Long id) { 26 | this.id = id; 27 | } 28 | 29 | public AnActiveEntity(Long id, String text) { 30 | this.id = id; 31 | this.text = text; 32 | } 33 | 34 | /** called by internal mechanisms, do not call yourself. */ 35 | public void __setDaoSession(DaoSession daoSession) { 36 | this.daoSession = daoSession; 37 | myDao = daoSession != null ? daoSession.getAnActiveEntityDao() : null; 38 | } 39 | 40 | public Long getId() { 41 | return id; 42 | } 43 | 44 | public void setId(Long id) { 45 | this.id = id; 46 | } 47 | 48 | public String getText() { 49 | return text; 50 | } 51 | 52 | public void setText(String text) { 53 | this.text = text; 54 | } 55 | 56 | /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */ 57 | public void delete() { 58 | if (myDao == null) { 59 | throw new DaoException("Entity is detached from DAO context"); 60 | } 61 | myDao.delete(this); 62 | } 63 | 64 | /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */ 65 | public void update() { 66 | if (myDao == null) { 67 | throw new DaoException("Entity is detached from DAO context"); 68 | } 69 | myDao.update(this); 70 | } 71 | 72 | /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */ 73 | public void refresh() { 74 | if (myDao == null) { 75 | throw new DaoException("Entity is detached from DAO context"); 76 | } 77 | myDao.refresh(this); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/test/AbstractDaoTestLongPk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.greenrobot.dao.test; 18 | 19 | import de.greenrobot.dao.AbstractDao; 20 | import de.greenrobot.dao.DaoLog; 21 | import de.greenrobot.dao.test.AbstractDaoTestSinglePk; 22 | 23 | /** 24 | * Base class for DAOs having a long/Long as a PK, which is quite common. 25 | * 26 | * @author Markus 27 | * 28 | * @param 29 | * DAO class 30 | * @param 31 | * Entity type of the DAO 32 | */ 33 | public abstract class AbstractDaoTestLongPk, T> extends AbstractDaoTestSinglePk { 34 | 35 | public AbstractDaoTestLongPk(Class daoClass) { 36 | super(daoClass); 37 | } 38 | 39 | /** @inheritdoc */ 40 | protected Long createRandomPk() { 41 | return random.nextLong(); 42 | } 43 | 44 | public void testAssignPk() { 45 | if (daoAccess.isEntityUpdateable()) { 46 | T entity1 = createEntity(null); 47 | if (entity1 != null) { 48 | T entity2 = createEntity(null); 49 | 50 | dao.insert(entity1); 51 | dao.insert(entity2); 52 | 53 | Long pk1 = daoAccess.getKey(entity1); 54 | assertNotNull(pk1); 55 | Long pk2 = daoAccess.getKey(entity2); 56 | assertNotNull(pk2); 57 | 58 | assertFalse(pk1.equals(pk2)); 59 | 60 | assertNotNull(dao.load(pk1)); 61 | assertNotNull(dao.load(pk2)); 62 | } else { 63 | DaoLog.d("Skipping testAssignPk for " + daoClass + " (createEntity returned null for null key)"); 64 | } 65 | } else { 66 | DaoLog.d("Skipping testAssignPk for not updateable " + daoClass); 67 | } 68 | } 69 | 70 | 71 | } -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/TestEntityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.entity; 19 | 20 | import de.greenrobot.dao.DaoException; 21 | import de.greenrobot.dao.test.AbstractDaoTestLongPk; 22 | import de.greenrobot.daotest.TestEntity; 23 | import de.greenrobot.daotest.TestEntityDao; 24 | 25 | public class TestEntityTest extends AbstractDaoTestLongPk { 26 | 27 | public TestEntityTest() { 28 | super(TestEntityDao.class); 29 | } 30 | 31 | @Override 32 | protected TestEntity createEntity(Long key) { 33 | TestEntity entity = new TestEntity(); 34 | entity.setId(key); 35 | entity.setSimpleStringNotNull("green"); 36 | return entity; 37 | } 38 | 39 | public void testRefresh() { 40 | TestEntity entity = createEntity(1l); 41 | entity.setSimpleInteger(42); 42 | entity.setSimpleString(null); 43 | dao.insert(entity); 44 | entity.setSimpleInteger(null); 45 | entity.setSimpleString("temp"); 46 | dao.refresh(entity); 47 | assertEquals(42, (int) entity.getSimpleInteger()); 48 | assertNull(entity.getSimpleString()); 49 | } 50 | 51 | public void testRefreshIllegal() { 52 | TestEntity entity = createEntity(1l); 53 | try { 54 | dao.refresh(entity); 55 | fail("Exception expected"); 56 | } catch (DaoException expected) { 57 | } 58 | dao.insert(entity); 59 | dao.delete(entity); 60 | try { 61 | dao.refresh(entity); 62 | fail("Exception expected"); 63 | } catch (DaoException expected) { 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/DateEntityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.entity; 19 | 20 | import java.util.Date; 21 | 22 | import de.greenrobot.dao.test.AbstractDaoTestLongPk; 23 | import de.greenrobot.daotest.DateEntity; 24 | import de.greenrobot.daotest.DateEntityDao; 25 | 26 | public class DateEntityTest extends AbstractDaoTestLongPk { 27 | 28 | public DateEntityTest() { 29 | super(DateEntityDao.class); 30 | } 31 | 32 | @Override 33 | protected DateEntity createEntity(Long key) { 34 | DateEntity entity = new DateEntity(); 35 | entity.setId(key); 36 | entity.setDateNotNull(new Date()); 37 | return entity; 38 | } 39 | 40 | public void testValues() { 41 | DateEntity entity = createEntity(1l); 42 | dao.insert(entity); 43 | 44 | DateEntity reloaded = dao.load(entity.getId()); 45 | assertNull(reloaded.getDate()); 46 | assertNotNull(reloaded.getDateNotNull()); 47 | assertEquals(entity.getDateNotNull(), reloaded.getDateNotNull()); 48 | } 49 | 50 | public void testValues2() { 51 | DateEntity entity = createEntity(1l); 52 | long t1=32479875; 53 | long t2=976345942443435235l; 54 | entity.setDate(new Date(t1)); 55 | entity.setDateNotNull(new Date(t2)); 56 | dao.insert(entity); 57 | 58 | DateEntity reloaded = dao.load(entity.getId()); 59 | assertNotNull(reloaded.getDate()); 60 | assertNotNull(reloaded.getDateNotNull()); 61 | assertEquals(t1, reloaded.getDate().getTime()); 62 | assertEquals(t2, reloaded.getDateNotNull().getTime()); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/DaoSessionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest; 19 | 20 | import android.app.Application; 21 | import de.greenrobot.dao.test.AbstractDaoSessionTest; 22 | 23 | public class DaoSessionTest extends AbstractDaoSessionTest { 24 | 25 | public DaoSessionTest() { 26 | super(DaoMaster.class); 27 | } 28 | 29 | public void testInsertAndLoad() { 30 | SimpleEntity entity = new SimpleEntity(); 31 | daoSession.insert(entity); 32 | Long id = entity.getId(); 33 | assertNotNull(id); 34 | SimpleEntity entity2 = daoSession.load(SimpleEntity.class, id); 35 | assertNotNull(entity2); 36 | } 37 | 38 | public void testIdentity() { 39 | SimpleEntity entity = new SimpleEntity(); 40 | daoSession.insert(entity); 41 | SimpleEntity entity2 = daoSession.load(SimpleEntity.class, entity.getId()); 42 | SimpleEntity entity3 = daoSession.load(SimpleEntity.class, entity.getId()); 43 | assertSame(entity, entity2); 44 | assertSame(entity, entity3); 45 | } 46 | 47 | public void testIdentityPerSession() { 48 | SimpleEntity entity = new SimpleEntity(); 49 | daoSession.insert(entity); 50 | DaoSession session2 = daoMaster.newSession(); 51 | SimpleEntity entity2 = session2.load(SimpleEntity.class, entity.getId()); 52 | assertNotSame(entity, entity2); 53 | } 54 | 55 | public void testSessionReset() { 56 | SimpleEntity entity = new SimpleEntity(); 57 | daoSession.insert(entity); 58 | daoSession.clear(); 59 | SimpleEntity entity2 = daoSession.load(SimpleEntity.class, entity.getId()); 60 | assertNotSame(entity, entity2); 61 | } 62 | } -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/test/AbstractDaoSessionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.greenrobot.dao.test; 18 | 19 | import java.lang.reflect.Constructor; 20 | import java.lang.reflect.Method; 21 | 22 | import android.app.Application; 23 | import android.database.sqlite.SQLiteDatabase; 24 | import de.greenrobot.dao.AbstractDaoMaster; 25 | import de.greenrobot.dao.AbstractDaoSession; 26 | 27 | /** 28 | * Base class for DAO (master) related testing. 29 | * 30 | * @author Markus 31 | * 32 | * @param 33 | * Type of a concrete DAO master 34 | */ 35 | public abstract class AbstractDaoSessionTest 36 | extends DbTest { 37 | 38 | private final Class daoMasterClass; 39 | protected T daoMaster; 40 | protected S daoSession; 41 | 42 | public AbstractDaoSessionTest(Class daoMasterClass) { 43 | this(daoMasterClass, true); 44 | } 45 | 46 | public AbstractDaoSessionTest(Class daoMasterClass, boolean inMemory) { 47 | super(inMemory); 48 | this.daoMasterClass = daoMasterClass; 49 | } 50 | 51 | public AbstractDaoSessionTest(Class appClass, Class daoMasterClass, boolean inMemory) { 52 | super(appClass, inMemory); 53 | this.daoMasterClass = daoMasterClass; 54 | } 55 | 56 | @SuppressWarnings("unchecked") 57 | @Override 58 | protected void setUp() { 59 | super.setUp(); 60 | try { 61 | Constructor constructor = daoMasterClass.getConstructor(SQLiteDatabase.class); 62 | daoMaster = constructor.newInstance(db); 63 | 64 | Method createTableMethod = daoMasterClass.getMethod("createAllTables", SQLiteDatabase.class, boolean.class); 65 | createTableMethod.invoke(null, db, false); 66 | } catch (Exception e) { 67 | throw new RuntimeException("Could not prepare DAO session test", e); 68 | } 69 | daoSession = (S) daoMaster.newSession(); 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /DaoCore/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /DaoExample/src-gen/de/greenrobot/daoexample/DaoSession.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daoexample; 2 | 3 | import android.database.sqlite.SQLiteDatabase; 4 | 5 | import java.util.Map; 6 | 7 | import de.greenrobot.dao.AbstractDao; 8 | import de.greenrobot.dao.DaoConfig; 9 | import de.greenrobot.dao.AbstractDaoSession; 10 | import de.greenrobot.dao.IdentityScopeType; 11 | 12 | import de.greenrobot.daoexample.Note; 13 | import de.greenrobot.daoexample.Customer; 14 | import de.greenrobot.daoexample.Order; 15 | 16 | import de.greenrobot.daoexample.NoteDao; 17 | import de.greenrobot.daoexample.CustomerDao; 18 | import de.greenrobot.daoexample.OrderDao; 19 | 20 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 21 | 22 | /** 23 | * {@inheritDoc} 24 | * 25 | * @see de.greenrobot.dao.AbstractDaoSession 26 | */ 27 | public class DaoSession extends AbstractDaoSession { 28 | 29 | private final DaoConfig noteDaoConfig; 30 | private final DaoConfig customerDaoConfig; 31 | private final DaoConfig orderDaoConfig; 32 | 33 | private final NoteDao noteDao; 34 | private final CustomerDao customerDao; 35 | private final OrderDao orderDao; 36 | 37 | public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map>, DaoConfig> 38 | daoConfigMap) { 39 | super(db); 40 | 41 | noteDaoConfig = daoConfigMap.get(NoteDao.class).clone(); 42 | noteDaoConfig.initIdentityScope(type); 43 | 44 | customerDaoConfig = daoConfigMap.get(CustomerDao.class).clone(); 45 | customerDaoConfig.initIdentityScope(type); 46 | 47 | orderDaoConfig = daoConfigMap.get(OrderDao.class).clone(); 48 | orderDaoConfig.initIdentityScope(type); 49 | 50 | noteDao = new NoteDao(noteDaoConfig, this); 51 | customerDao = new CustomerDao(customerDaoConfig, this); 52 | orderDao = new OrderDao(orderDaoConfig, this); 53 | 54 | registerDao(Note.class, noteDao); 55 | registerDao(Customer.class, customerDao); 56 | registerDao(Order.class, orderDao); 57 | } 58 | 59 | public void clear() { 60 | noteDaoConfig.getIdentityScope().clear(); 61 | customerDaoConfig.getIdentityScope().clear(); 62 | orderDaoConfig.getIdentityScope().clear(); 63 | } 64 | 65 | public void deleteAllData() { 66 | noteDao.deleteAll(); 67 | customerDao.deleteAll(); 68 | orderDao.deleteAll(); 69 | } 70 | 71 | 72 | public NoteDao getNoteDao() { 73 | return noteDao; 74 | } 75 | 76 | public CustomerDao getCustomerDao() { 77 | return customerDao; 78 | } 79 | 80 | public OrderDao getOrderDao() { 81 | return orderDao; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /DaoGenerator/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/test/DbTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.greenrobot.dao.test; 18 | 19 | import java.util.Random; 20 | 21 | import android.app.Application; 22 | import android.content.Context; 23 | import android.database.sqlite.SQLiteDatabase; 24 | import android.test.ApplicationTestCase; 25 | import de.greenrobot.dao.DbUtils; 26 | 27 | /** 28 | * Base class for database related testing. Prepares an in-memory or an file-based DB. 29 | * 30 | * @author Markus 31 | * 32 | */ 33 | public abstract class DbTest extends ApplicationTestCase { 34 | 35 | protected SQLiteDatabase db; 36 | protected Random random; 37 | protected final boolean inMemory; 38 | 39 | public DbTest() { 40 | this(true); 41 | } 42 | 43 | @SuppressWarnings("unchecked") 44 | public DbTest(boolean inMemory) { 45 | this((Class) Application.class, inMemory); 46 | } 47 | 48 | public DbTest(Class appClass, boolean inMemory) { 49 | super(appClass); 50 | this.inMemory = inMemory; 51 | random = new Random(); 52 | } 53 | 54 | @Override 55 | protected void setUp() { 56 | try { 57 | super.setUp(); 58 | } catch (Exception e) { 59 | throw new RuntimeException(e); 60 | } 61 | createApplication(); 62 | setUpDb(); 63 | } 64 | 65 | /** Override if you create your own DB */ 66 | protected void setUpDb() { 67 | if (inMemory) { 68 | db = SQLiteDatabase.create(null); 69 | } else { 70 | getApplication().deleteDatabase("test-db"); 71 | db = getApplication().openOrCreateDatabase("test-db", Context.MODE_PRIVATE, null); 72 | } 73 | } 74 | 75 | @Override 76 | protected void tearDown() throws Exception { 77 | db.close(); 78 | if (!inMemory) { 79 | getApplication().deleteDatabase("test-db"); 80 | } 81 | super.tearDown(); 82 | } 83 | 84 | protected void logTableDump(String tablename) { 85 | DbUtils.logTableDump(db, tablename); 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/TestEntityTestBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.entity; 19 | 20 | import java.util.ArrayList; 21 | 22 | import de.greenrobot.dao.LazyList; 23 | import de.greenrobot.dao.test.AbstractDaoTest; 24 | import de.greenrobot.daotest.TestEntity; 25 | import de.greenrobot.daotest.TestEntityDao; 26 | 27 | public abstract class TestEntityTestBase extends AbstractDaoTest { 28 | 29 | public TestEntityTestBase() { 30 | super(TestEntityDao.class); 31 | } 32 | 33 | protected TestEntity createEntity(int simpleInteger, String simpleString) { 34 | TestEntity entity = new TestEntity(); 35 | entity.setId(null); 36 | entity.setSimpleStringNotNull("green"); 37 | entity.setSimpleInteger(simpleInteger); 38 | entity.setSimpleString(simpleString); 39 | return entity; 40 | } 41 | 42 | protected ArrayList insert(int count) { 43 | ArrayList list = new ArrayList(); 44 | for (int i = 0; i < count; i++) { 45 | TestEntity entity = createEntity(getSimpleInteger(i), getSimpleString(i)); 46 | list.add(entity); 47 | } 48 | dao.insertInTx(list); 49 | return list; 50 | } 51 | 52 | protected String getSimpleString(int i) { 53 | return "String" + (i + 100); 54 | } 55 | 56 | protected int getSimpleInteger(int i) { 57 | return 100 + i; 58 | } 59 | 60 | protected void assertIds(ArrayList list, LazyList list2) { 61 | for (int i = 0; i < list.size(); i++) { 62 | TestEntity entity = list.get(i); 63 | TestEntity lazyEntity = list2.get(i); 64 | assertIds(entity, lazyEntity); 65 | } 66 | } 67 | 68 | protected void assertIds(TestEntity entity, TestEntity entity2) { 69 | assertEquals(entity.getId(), entity2.getId()); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /DaoGenerator/src-test/de/greenrobot/daogenerator/test/SimpleDaoGeneratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daogenerator.test; 19 | 20 | import static org.junit.Assert.assertEquals; 21 | import static org.junit.Assert.assertFalse; 22 | import static org.junit.Assert.assertTrue; 23 | 24 | import java.io.File; 25 | 26 | import org.junit.Test; 27 | 28 | import de.greenrobot.daogenerator.DaoGenerator; 29 | import de.greenrobot.daogenerator.DaoUtil; 30 | import de.greenrobot.daogenerator.Entity; 31 | import de.greenrobot.daogenerator.Property; 32 | import de.greenrobot.daogenerator.Schema; 33 | 34 | public class SimpleDaoGeneratorTest { 35 | 36 | @Test 37 | public void testMinimalSchema() throws Exception { 38 | Schema schema = new Schema(1, "de.greenrobot.testdao"); 39 | Entity adressTable = schema.addEntity("Adresse"); 40 | Property idProperty = adressTable.addIdProperty().getProperty(); 41 | adressTable.addIntProperty("count").index(); 42 | adressTable.addIntProperty("dummy").notNull(); 43 | assertEquals(1, schema.getEntities().size()); 44 | assertEquals(3, adressTable.getProperties().size()); 45 | 46 | File daoFile = new File("test-out/de/greenrobot/testdao/" + adressTable.getClassName() + "Dao.java"); 47 | daoFile.delete(); 48 | assertFalse(daoFile.exists()); 49 | 50 | new DaoGenerator().generateAll(schema, "test-out"); 51 | 52 | assertEquals("PRIMARY KEY", idProperty.getConstraints()); 53 | assertTrue(daoFile.toString(), daoFile.exists()); 54 | } 55 | 56 | @Test 57 | public void testDbName() { 58 | assertEquals("NORMAL", DaoUtil.dbName("normal")); 59 | assertEquals("NORMAL", DaoUtil.dbName("Normal")); 60 | assertEquals("CAMEL_CASE", DaoUtil.dbName("CamelCase")); 61 | assertEquals("CAMEL_CASE_THREE", DaoUtil.dbName("CamelCaseThree")); 62 | assertEquals("CAMEL_CASE_XXXX", DaoUtil.dbName("CamelCaseXXXX")); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/TestEntityIdentityScopeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.entity; 19 | 20 | import de.greenrobot.dao.IdentityScopeLong; 21 | import de.greenrobot.daotest.TestEntity; 22 | 23 | public class TestEntityIdentityScopeTest extends TestEntityTest { 24 | @Override 25 | protected void setUp() { 26 | setIdentityScopeBeforeSetUp(new IdentityScopeLong()); 27 | super.setUp(); 28 | } 29 | 30 | public void testLoadIdScope() { 31 | TestEntity entity = createEntity(null); 32 | dao.insert(entity); 33 | TestEntity entity2 = dao.load(entity.getId()); 34 | TestEntity entity3 = dao.load(entity.getId()); 35 | 36 | assertSame(entity, entity2); 37 | assertSame(entity2, entity3); 38 | } 39 | 40 | public void testDetach() { 41 | TestEntity entity = createEntity(null); 42 | dao.insert(entity); 43 | dao.detach(entity); 44 | TestEntity entity2 = dao.load(entity.getId()); 45 | dao.detach(entity2); 46 | TestEntity entity3 = dao.load(entity.getId()); 47 | 48 | assertNotSame(entity, entity2); 49 | assertNotSame(entity2, entity3); 50 | assertNotSame(entity, entity3); 51 | } 52 | 53 | public void testDetachOther() { 54 | TestEntity entity = createEntity(null); 55 | dao.insert(entity); 56 | dao.detach(entity); 57 | TestEntity entity2 = dao.load(entity.getId()); 58 | dao.detach(entity); 59 | TestEntity entity3 = dao.load(entity.getId()); 60 | 61 | assertSame(entity2, entity3); 62 | } 63 | 64 | public void testLoadAllScope() { 65 | TestEntity entity = createEntity(null); 66 | dao.insert(entity); 67 | TestEntity entity2 = dao.loadAll().get(0); 68 | TestEntity entity3 = dao.loadAll().get(0); 69 | 70 | assertSame(entity, entity2); 71 | assertSame(entity2, entity3); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | greenDAO 2 | ======== 3 | greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases. Being highly optimized for Android, greenDAO offers great performance and consumes minimal memory. 4 | 5 | Home page, documentation, and support links: http://greendao-orm.com/ 6 | 7 | Release History 8 | --------------- 9 | ### V1.2.0 (2012-06-08): Feature release 10 | * Limited support of String PKs (no relations using String FKs yet) 11 | * Fixed index creation (please update your schema) 12 | * Added CountQuery for creating SELECT COUNT (*) queries with QueryBuilder 13 | * Added getDatabase in DaoMaster, DaoSession, and Dao 14 | * Added insertOrReplaceInTx in Dao 15 | * Added deleteInTx in Dao 16 | * Added autoincrement() creating AUTOINCREMENT PKs 17 | * Made DAOs and DaoSessions in active entities transient (allows serialization of entities) 18 | * Minor fixes 19 | 20 | ### V1.1.2 (2012-03-26): ADT 17 support for demo project 21 | * Demo projects works with ADT 17 (moved greendao.jar into libs) 22 | * CREATE/DROP TABLE may be skipped for entity types: This allows having multiple entity tapes operate on one table 23 | * Minor improvements 24 | 25 | ### V1.1.1 (2012-02-14): Mini bugfix&feature release 26 | * Added NOT IN condition for QueryBuilder 27 | * Fix for Roboelectric (Issue #22) 28 | * Minor fix (Issue #5) 29 | 30 | ### V1.1.0 (2012-02-13): Feature release 31 | * DeleteQuery for bulk deletes 32 | * Entities may implement Java interfaces 33 | * Entities may extend a Java class 34 | * Added LIMIT and OFFSET support for QueryBuilder and Query 35 | * Convenience methods to add named relationships 36 | * SQL scripts are executed in a transaction by default 37 | * Fixed queries with special column names (SQL keywords) 38 | * Changed default names for to-many relations to end with "List" 39 | * ORDER BY uses LOCALIZED collation for strings by default 40 | 41 | ### V1.0.1 (2011-10-30): Bugfix release 42 | * Fixed generation of to-many relations 43 | * Fixed generated import statements when entities/DAO are not in the same package 44 | 45 | ### V1.0.0 (2011-10-24): First open source release 46 | * To-many relations (lazily loaded on the entities) 47 | * To-many relations with custom join properties 48 | * Active entities can be updated, refreshed, and deleted directly 49 | * Significant performance improvements (faster identity scope, faster database result parser) 50 | * "Keep sections" for custom code in entities were added that won't be overwritten during code generation 51 | * Other minor improvements 52 | 53 | ### Third preview (2011-08-19) 54 | http://greendao-orm.com/2011/08/19/query-builder-and-lazy-loading-lists/ 55 | 56 | ### Second preview (2011-08-12) 57 | http://greendao-orm.com/2011/08/12/greendao-2nd-preview/ 58 | 59 | ### First public release (2011-08-04) 60 | http://greendao-orm.com/2011/08/04/greendao-public-release/ -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/DaoLog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.greenrobot.dao; 18 | 19 | import android.util.Log; 20 | 21 | /** 22 | * Internal greenDAO logger class. A wrapper around the Android Log class providing a static Log Tag. 23 | * 24 | * @author markus 25 | * 26 | */ 27 | public class DaoLog { 28 | private final static String TAG = "greenDAO"; 29 | 30 | public static final int VERBOSE = 2; 31 | public static final int DEBUG = 3; 32 | public static final int INFO = 4; 33 | public static final int WARN = 5; 34 | public static final int ERROR = 6; 35 | public static final int ASSERT = 7; 36 | 37 | public static boolean isLoggable(int level) { 38 | return Log.isLoggable(TAG, level); 39 | } 40 | 41 | public static String getStackTraceString(Throwable th) { 42 | return Log.getStackTraceString(th); 43 | } 44 | 45 | public static int println(int level, String msg) { 46 | return Log.println(level, TAG, msg); 47 | } 48 | 49 | public static int v(String msg) { 50 | return Log.v(TAG, msg); 51 | } 52 | 53 | public static int v(String msg, Throwable th) { 54 | return Log.v(TAG, msg, th); 55 | } 56 | 57 | public static int d(String msg) { 58 | return Log.d(TAG, msg); 59 | } 60 | 61 | public static int d(String msg, Throwable th) { 62 | return Log.d(TAG, msg, th); 63 | } 64 | 65 | public static int i(String msg) { 66 | return Log.i(TAG, msg); 67 | } 68 | 69 | public static int i(String msg, Throwable th) { 70 | return Log.i(TAG, msg, th); 71 | } 72 | 73 | public static int w(String msg) { 74 | return Log.w(TAG, msg); 75 | } 76 | 77 | public static int w(String msg, Throwable th) { 78 | return Log.w(TAG, msg, th); 79 | } 80 | 81 | public static int w(Throwable th) { 82 | return Log.w(TAG, th); 83 | } 84 | 85 | public static int e(String msg) { 86 | return Log.w(TAG, msg); 87 | } 88 | 89 | public static int e(String msg, Throwable th) { 90 | return Log.e(TAG, msg, th); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /DaoGenerator/src-template/entity.ftl: -------------------------------------------------------------------------------- 1 | <#include "*/annotation.ftl"> 2 | <#-- 3 | 4 | Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 5 | 6 | This file is part of greenDAO Generator. 7 | 8 | greenDAO Generator is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | greenDAO Generator is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with greenDAO Generator. If not, see . 19 | 20 | --> 21 | package ${entity.javaPackage}; 22 | 23 | <#if entity.additionalImportsEntity?has_content> 24 | <#list entity.additionalImportsEntity as additionalImport> 25 | import ${additionalImport}; 26 | 27 | 28 | <#list entity.imports as import> 29 | import ${import}; 30 | 31 | <#list entity.properties as property> 32 | <#list property.imports as import> 33 | import ${import}; 34 | 35 | 36 | 37 | <#if entity.hasKeepSections> 38 | // THIS CODE IS GENERATED BY greenDAO, EDIT ONLY INSIDE THE "KEEP"-SECTIONS 39 | 40 | // KEEP INCLUDES - put your custom includes here 41 | <#if keepIncludes?has_content>${keepIncludes!}// KEEP INCLUDES END 42 | <#else> 43 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 44 | 45 | /** 46 | * Entity mapped to table ${entity.tableName}. 47 | */ 48 | <@print_annotations entity.annotations, ""/> 49 | public class ${entity.className} extends ${entity.classNameBase} { 50 | <#if entity.hasKeepSections> 51 | // KEEP FIELDS - put your custom fields here 52 | ${keepFields!} // KEEP FIELDS END 53 | 54 | <#if entity.constructors> 55 | public ${entity.className}() { 56 | } 57 | <#if entity.propertiesPk?has_content && entity.propertiesPk?size != entity.properties?size> 58 | 59 | public ${entity.className}(<#list entity.propertiesPk as 60 | property>${property.javaType} ${property.propertyName}<#if property_has_next>, ) { 61 | <#list entity.propertiesPk as property> 62 | super(${property.propertyName}); 63 | 64 | } 65 | 66 | 67 | public ${entity.className}(<#list entity.properties as 68 | property>${property.javaType} ${property.propertyName}<#if property_has_next>, ) { 69 | super(<#list entity.properties as 70 | property>${property.propertyName}<#if property_has_next>, ); 71 | } 72 | 73 | 74 | <#if entity.hasKeepSections> 75 | // KEEP METHODS - put your custom methods here 76 | ${keepMethods!} // KEEP METHODS END 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /DaoGenerator/src/de/greenrobot/daogenerator/PropertyOrderList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daogenerator; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | public class PropertyOrderList { 24 | private List properties; 25 | private List propertiesOrder; 26 | 27 | public PropertyOrderList() { 28 | properties = new ArrayList(); 29 | propertiesOrder = new ArrayList(); 30 | } 31 | 32 | public void addProperty(Property property) { 33 | properties.add(property); 34 | propertiesOrder.add(null); 35 | } 36 | 37 | public void addPropertyAsc(Property property) { 38 | properties.add(property); 39 | propertiesOrder.add("ASC"); 40 | } 41 | 42 | public void addPropertyDesc(Property property) { 43 | properties.add(property); 44 | propertiesOrder.add("DESC"); 45 | } 46 | 47 | public void addOrderRaw(String order) { 48 | properties.add(null); 49 | propertiesOrder.add(order); 50 | } 51 | 52 | public List getProperties() { 53 | return properties; 54 | } 55 | 56 | List getPropertiesOrder() { 57 | return propertiesOrder; 58 | } 59 | 60 | public String getCommaSeparatedString() { 61 | StringBuilder builder = new StringBuilder(); 62 | int size = properties.size(); 63 | for (int i = 0; i < size; i++) { 64 | Property property = properties.get(i); 65 | String order = propertiesOrder.get(i); 66 | if (property != null) { 67 | builder.append(property.getColumnName()).append(' '); 68 | } 69 | if (order != null) { 70 | builder.append(order); 71 | } 72 | if (i < size - 1) { 73 | builder.append(','); 74 | } 75 | } 76 | return builder.toString(); 77 | } 78 | 79 | public boolean isEmpty() { 80 | return properties.isEmpty(); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/LongHashMapTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest; 19 | 20 | import java.util.Random; 21 | 22 | import junit.framework.TestCase; 23 | import de.greenrobot.dao.LongHashMap; 24 | 25 | public class LongHashMapTest extends TestCase { 26 | 27 | Random random; 28 | private String traceName; 29 | private long start; 30 | 31 | public LongHashMapTest() { 32 | this.random = new Random(); 33 | } 34 | 35 | public void testLongHashMapSimple() { 36 | LongHashMap map = new LongHashMap(); 37 | 38 | map.put(1l << 33, "OK"); 39 | assertNull(map.get(0)); 40 | assertEquals("OK", map.get(1l << 33)); 41 | 42 | long keyLong = 0x7fffffffl << 33l + 14; 43 | assertNull(map.remove(keyLong)); 44 | map.put(keyLong, "OK"); 45 | assertTrue(map.containsKey(keyLong)); 46 | assertEquals("OK", map.remove(keyLong)); 47 | 48 | keyLong = Long.MAX_VALUE; 49 | map.put(keyLong, "OK"); 50 | assertTrue(map.containsKey(keyLong)); 51 | 52 | keyLong = 8064216579113853113l; 53 | map.put(keyLong, "OK"); 54 | assertTrue(map.containsKey(keyLong)); 55 | 56 | } 57 | 58 | public void testLongHashMapRandom() { 59 | LongHashMap map = new LongHashMap(); 60 | for (int i = 0; i < 5000; i++) { 61 | long key = random.nextLong(); 62 | String value = "Value-" + key; 63 | map.put(key, value); 64 | assertTrue("" + key, map.containsKey(key)); 65 | 66 | int keyInt = (int) key; 67 | String valueInt = "Value-" + keyInt; 68 | map.put(keyInt, valueInt); 69 | assertTrue(map.containsKey(keyInt)); 70 | 71 | assertEquals(value, map.get(key)); 72 | assertEquals(valueInt, map.get(keyInt)); 73 | 74 | assertEquals(value, map.remove(key)); 75 | assertEquals(valueInt, map.remove(keyInt)); 76 | 77 | assertNull(map.get(key)); 78 | assertNull(map.get(keyInt)); 79 | } 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /DaoExample/src-gen/de/greenrobot/daoexample/DaoMaster.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daoexample; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteDatabase.CursorFactory; 6 | import android.database.sqlite.SQLiteOpenHelper; 7 | import android.util.Log; 8 | import de.greenrobot.dao.AbstractDaoMaster; 9 | import de.greenrobot.dao.IdentityScopeType; 10 | 11 | import de.greenrobot.daoexample.NoteDao; 12 | import de.greenrobot.daoexample.CustomerDao; 13 | import de.greenrobot.daoexample.OrderDao; 14 | 15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 16 | /** 17 | * Master of DAO (schema version 3): knows all DAOs. 18 | */ 19 | public class DaoMaster extends AbstractDaoMaster { 20 | public static final int SCHEMA_VERSION = 3; 21 | 22 | /** Creates underlying database table using DAOs. */ 23 | public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { 24 | NoteDao.createTable(db, ifNotExists); 25 | CustomerDao.createTable(db, ifNotExists); 26 | OrderDao.createTable(db, ifNotExists); 27 | } 28 | 29 | /** Drops underlying database table using DAOs. */ 30 | public static void dropAllTables(SQLiteDatabase db, boolean ifExists) { 31 | NoteDao.dropTable(db, ifExists); 32 | CustomerDao.dropTable(db, ifExists); 33 | OrderDao.dropTable(db, ifExists); 34 | } 35 | 36 | public static abstract class OpenHelper extends SQLiteOpenHelper { 37 | 38 | public OpenHelper(Context context, String name, CursorFactory factory) { 39 | super(context, name, factory, SCHEMA_VERSION); 40 | } 41 | 42 | @Override 43 | public void onCreate(SQLiteDatabase db) { 44 | Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); 45 | createAllTables(db, false); 46 | } 47 | } 48 | 49 | /** WARNING: Drops all table on Upgrade! Use only during development. */ 50 | public static class DevOpenHelper extends OpenHelper { 51 | public DevOpenHelper(Context context, String name, CursorFactory factory) { 52 | super(context, name, factory); 53 | } 54 | 55 | @Override 56 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 57 | Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); 58 | dropAllTables(db, true); 59 | onCreate(db); 60 | } 61 | } 62 | 63 | public DaoMaster(SQLiteDatabase db) { 64 | super(db, SCHEMA_VERSION); 65 | registerDaoClass(NoteDao.class); 66 | registerDaoClass(CustomerDao.class); 67 | registerDaoClass(OrderDao.class); 68 | } 69 | 70 | public DaoSession newSession() { 71 | return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); 72 | } 73 | 74 | public DaoSession newSession(IdentityScopeType type) { 75 | return new DaoSession(db, type, daoConfigMap); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /DaoGenerator/src/de/greenrobot/daogenerator/DaoUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daogenerator; 19 | 20 | import java.io.*; 21 | 22 | /** Internal API */ 23 | public class DaoUtil { 24 | public static String dbName(String javaName) { 25 | StringBuilder builder = new StringBuilder(javaName); 26 | for (int i = 1; i < builder.length(); i++) { 27 | boolean lastWasUpper = Character.isUpperCase(builder.charAt(i - 1)); 28 | boolean isUpper = Character.isUpperCase(builder.charAt(i)); 29 | if (isUpper && !lastWasUpper) { 30 | builder.insert(i, '_'); 31 | i++; 32 | } 33 | } 34 | return builder.toString().toUpperCase(); 35 | } 36 | 37 | public static byte[] readAllBytes(InputStream in) throws IOException { 38 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 39 | copyAllBytes(in, out); 40 | return out.toByteArray(); 41 | } 42 | 43 | public static byte[] readAllBytes(File file) throws IOException { 44 | FileInputStream is = new FileInputStream(file); 45 | try { 46 | return DaoUtil.readAllBytes(is); 47 | } finally { 48 | is.close(); 49 | } 50 | } 51 | 52 | public static byte[] readAllBytes(String filename) throws IOException { 53 | FileInputStream is = new FileInputStream(filename); 54 | try { 55 | return DaoUtil.readAllBytes(is); 56 | } finally { 57 | is.close(); 58 | } 59 | } 60 | 61 | /** 62 | * Copies all available data from in to out without closing any stream. 63 | * 64 | * @return number of bytes copied 65 | */ 66 | public static int copyAllBytes(InputStream in, OutputStream out) throws IOException { 67 | int byteCount = 0; 68 | byte[] buffer = new byte[4096]; 69 | while (true) { 70 | int read = in.read(buffer); 71 | if (read == -1) { 72 | break; 73 | } 74 | out.write(buffer, 0, read); 75 | byteCount += read; 76 | } 77 | return byteCount; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/StringKeyValueEntityIdentityScopeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.entity; 19 | 20 | import de.greenrobot.dao.IdentityScopeObject; 21 | import de.greenrobot.daotest.StringKeyValueEntity; 22 | 23 | public class StringKeyValueEntityIdentityScopeTest extends StringKeyValueEntityTest { 24 | @Override 25 | protected void setUp() { 26 | setIdentityScopeBeforeSetUp(new IdentityScopeObject()); 27 | super.setUp(); 28 | } 29 | 30 | public void testLoadIdScope() { 31 | StringKeyValueEntity entity = createEntityWithRandomPk(); 32 | dao.insert(entity); 33 | StringKeyValueEntity entity2 = dao.load(entity.getKey()); 34 | StringKeyValueEntity entity3 = dao.load(entity.getKey()); 35 | 36 | assertSame(entity, entity2); 37 | assertSame(entity2, entity3); 38 | } 39 | 40 | public void testDetach() { 41 | StringKeyValueEntity entity = createEntityWithRandomPk(); 42 | dao.insert(entity); 43 | dao.detach(entity); 44 | StringKeyValueEntity entity2 = dao.load(entity.getKey()); 45 | dao.detach(entity2); 46 | StringKeyValueEntity entity3 = dao.load(entity.getKey()); 47 | 48 | assertNotSame(entity, entity2); 49 | assertNotSame(entity2, entity3); 50 | assertNotSame(entity, entity3); 51 | } 52 | 53 | public void testDetachOther() { 54 | StringKeyValueEntity entity = createEntityWithRandomPk(); 55 | dao.insert(entity); 56 | dao.detach(entity); 57 | StringKeyValueEntity entity2 = dao.load(entity.getKey()); 58 | dao.detach(entity); 59 | StringKeyValueEntity entity3 = dao.load(entity.getKey()); 60 | 61 | assertSame(entity2, entity3); 62 | } 63 | 64 | public void testLoadAllScope() { 65 | StringKeyValueEntity entity = createEntityWithRandomPk(); 66 | dao.insert(entity); 67 | StringKeyValueEntity entity2 = dao.loadAll().get(0); 68 | StringKeyValueEntity entity3 = dao.loadAll().get(0); 69 | 70 | assertSame(entity, entity2); 71 | assertSame(entity2, entity3); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest/SpecialNamesEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 4 | /** 5 | * Entity mapped to table SPECIAL_NAMES_ENTITY. 6 | */ 7 | public class SpecialNamesEntity { 8 | 9 | private Long id; 10 | private String count; 11 | private String select; 12 | private String sum; 13 | private String avg; 14 | private String join; 15 | private String distinct; 16 | private String on; 17 | private String index; 18 | private Integer order; 19 | 20 | public SpecialNamesEntity() { 21 | } 22 | 23 | public SpecialNamesEntity(Long id) { 24 | this.id = id; 25 | } 26 | 27 | public SpecialNamesEntity(Long id, String count, String select, String sum, String avg, String join, String distinct, String on, String index, Integer order) { 28 | this.id = id; 29 | this.count = count; 30 | this.select = select; 31 | this.sum = sum; 32 | this.avg = avg; 33 | this.join = join; 34 | this.distinct = distinct; 35 | this.on = on; 36 | this.index = index; 37 | this.order = order; 38 | } 39 | 40 | public Long getId() { 41 | return id; 42 | } 43 | 44 | public void setId(Long id) { 45 | this.id = id; 46 | } 47 | 48 | public String getCount() { 49 | return count; 50 | } 51 | 52 | public void setCount(String count) { 53 | this.count = count; 54 | } 55 | 56 | public String getSelect() { 57 | return select; 58 | } 59 | 60 | public void setSelect(String select) { 61 | this.select = select; 62 | } 63 | 64 | public String getSum() { 65 | return sum; 66 | } 67 | 68 | public void setSum(String sum) { 69 | this.sum = sum; 70 | } 71 | 72 | public String getAvg() { 73 | return avg; 74 | } 75 | 76 | public void setAvg(String avg) { 77 | this.avg = avg; 78 | } 79 | 80 | public String getJoin() { 81 | return join; 82 | } 83 | 84 | public void setJoin(String join) { 85 | this.join = join; 86 | } 87 | 88 | public String getDistinct() { 89 | return distinct; 90 | } 91 | 92 | public void setDistinct(String distinct) { 93 | this.distinct = distinct; 94 | } 95 | 96 | public String getOn() { 97 | return on; 98 | } 99 | 100 | public void setOn(String on) { 101 | this.on = on; 102 | } 103 | 104 | public String getIndex() { 105 | return index; 106 | } 107 | 108 | public void setIndex(String index) { 109 | this.index = index; 110 | } 111 | 112 | public Integer getOrder() { 113 | return order; 114 | } 115 | 116 | public void setOrder(Integer order) { 117 | this.order = order; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest/AbcdefEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 4 | /** 5 | * Entity mapped to table ABCDEF_ENTITY. 6 | */ 7 | public class AbcdefEntity { 8 | 9 | private Long id; 10 | private Integer a; 11 | private Integer b; 12 | private Integer c; 13 | private Integer d; 14 | private Integer e; 15 | private Integer f; 16 | private Integer g; 17 | private Integer h; 18 | private Integer j; 19 | private Integer i; 20 | private Integer k; 21 | 22 | public AbcdefEntity() { 23 | } 24 | 25 | public AbcdefEntity(Long id) { 26 | this.id = id; 27 | } 28 | 29 | public AbcdefEntity(Long id, Integer a, Integer b, Integer c, Integer d, Integer e, Integer f, Integer g, Integer h, Integer j, Integer i, Integer k) { 30 | this.id = id; 31 | this.a = a; 32 | this.b = b; 33 | this.c = c; 34 | this.d = d; 35 | this.e = e; 36 | this.f = f; 37 | this.g = g; 38 | this.h = h; 39 | this.j = j; 40 | this.i = i; 41 | this.k = k; 42 | } 43 | 44 | public Long getId() { 45 | return id; 46 | } 47 | 48 | public void setId(Long id) { 49 | this.id = id; 50 | } 51 | 52 | public Integer getA() { 53 | return a; 54 | } 55 | 56 | public void setA(Integer a) { 57 | this.a = a; 58 | } 59 | 60 | public Integer getB() { 61 | return b; 62 | } 63 | 64 | public void setB(Integer b) { 65 | this.b = b; 66 | } 67 | 68 | public Integer getC() { 69 | return c; 70 | } 71 | 72 | public void setC(Integer c) { 73 | this.c = c; 74 | } 75 | 76 | public Integer getD() { 77 | return d; 78 | } 79 | 80 | public void setD(Integer d) { 81 | this.d = d; 82 | } 83 | 84 | public Integer getE() { 85 | return e; 86 | } 87 | 88 | public void setE(Integer e) { 89 | this.e = e; 90 | } 91 | 92 | public Integer getF() { 93 | return f; 94 | } 95 | 96 | public void setF(Integer f) { 97 | this.f = f; 98 | } 99 | 100 | public Integer getG() { 101 | return g; 102 | } 103 | 104 | public void setG(Integer g) { 105 | this.g = g; 106 | } 107 | 108 | public Integer getH() { 109 | return h; 110 | } 111 | 112 | public void setH(Integer h) { 113 | this.h = h; 114 | } 115 | 116 | public Integer getJ() { 117 | return j; 118 | } 119 | 120 | public void setJ(Integer j) { 121 | this.j = j; 122 | } 123 | 124 | public Integer getI() { 125 | return i; 126 | } 127 | 128 | public void setI(Integer i) { 129 | this.i = i; 130 | } 131 | 132 | public Integer getK() { 133 | return k; 134 | } 135 | 136 | public void setK(Integer k) { 137 | this.k = k; 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/query/CountQueryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.query; 19 | 20 | import java.util.ArrayList; 21 | 22 | import de.greenrobot.dao.CountQuery; 23 | import de.greenrobot.dao.Query; 24 | import de.greenrobot.dao.QueryBuilder; 25 | import de.greenrobot.daotest.TestEntity; 26 | import de.greenrobot.daotest.TestEntityDao.Properties; 27 | import de.greenrobot.daotest.entity.TestEntityTestBase; 28 | 29 | // TODO more tests 30 | public class CountQueryTest extends TestEntityTestBase { 31 | @Override 32 | protected void setUp() { 33 | super.setUp(); 34 | QueryBuilder.LOG_SQL = true; 35 | QueryBuilder.LOG_VALUES = true; 36 | } 37 | 38 | public void testCountQuerySimple() { 39 | int value = getSimpleInteger(1); 40 | CountQuery query = dao.queryBuilder().where(Properties.SimpleInteger.eq(value)).buildCount(); 41 | assertEquals(0, query.count()); 42 | 43 | ArrayList inserted = insert(3); 44 | assertEquals(1, query.count()); 45 | 46 | inserted.get(2).setSimpleInteger(value); 47 | dao.update(inserted.get(2)); 48 | assertEquals(2, query.count()); 49 | 50 | dao.deleteAll(); 51 | assertEquals(0, query.count()); 52 | } 53 | 54 | public void testCountQueryChangeParameter() { 55 | insert(3); 56 | 57 | String value = "not existing value"; 58 | CountQuery query = dao.queryBuilder().where(Properties.SimpleString.eq(value)).buildCount(); 59 | assertEquals(0, query.count()); 60 | query.setParameter(0, getSimpleString(1)); 61 | assertEquals(1, query.count()); 62 | query.setParameter(0, getSimpleString(2)); 63 | assertEquals(1, query.count()); 64 | query.setParameter(0, "you won't find me either"); 65 | assertEquals(0, query.count()); 66 | } 67 | 68 | public void testBuildQueryAndCountQuery() { 69 | insert(3); 70 | int value = getSimpleInteger(1); 71 | 72 | QueryBuilder builder = dao.queryBuilder().where(Properties.SimpleInteger.eq(value)); 73 | Query query = builder.build(); 74 | CountQuery countQuery = builder.buildCount(); 75 | 76 | assertEquals(1, query.list().size()); 77 | assertEquals(1, countQuery.count()); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest2/dao/DaoMaster.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest2.dao; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteDatabase.CursorFactory; 6 | import android.database.sqlite.SQLiteOpenHelper; 7 | import android.util.Log; 8 | import de.greenrobot.dao.AbstractDaoMaster; 9 | import de.greenrobot.dao.IdentityScopeType; 10 | 11 | import de.greenrobot.daotest2.dao.KeepEntityDao; 12 | import de.greenrobot.daotest2.dao.ToManyTarget2Dao; 13 | import de.greenrobot.daotest2.to1_specialdao.ToOneTarget2Dao; 14 | import de.greenrobot.daotest2.specialdao.RelationSource2Dao; 15 | 16 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 17 | /** 18 | * Master of DAO (schema version 1): knows all DAOs. 19 | */ 20 | public class DaoMaster extends AbstractDaoMaster { 21 | public static final int SCHEMA_VERSION = 1; 22 | 23 | /** Creates underlying database table using DAOs. */ 24 | public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { 25 | KeepEntityDao.createTable(db, ifNotExists); 26 | ToManyTarget2Dao.createTable(db, ifNotExists); 27 | ToOneTarget2Dao.createTable(db, ifNotExists); 28 | RelationSource2Dao.createTable(db, ifNotExists); 29 | } 30 | 31 | /** Drops underlying database table using DAOs. */ 32 | public static void dropAllTables(SQLiteDatabase db, boolean ifExists) { 33 | KeepEntityDao.dropTable(db, ifExists); 34 | ToManyTarget2Dao.dropTable(db, ifExists); 35 | ToOneTarget2Dao.dropTable(db, ifExists); 36 | RelationSource2Dao.dropTable(db, ifExists); 37 | } 38 | 39 | public static abstract class OpenHelper extends SQLiteOpenHelper { 40 | 41 | public OpenHelper(Context context, String name, CursorFactory factory) { 42 | super(context, name, factory, SCHEMA_VERSION); 43 | } 44 | 45 | @Override 46 | public void onCreate(SQLiteDatabase db) { 47 | Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); 48 | createAllTables(db, false); 49 | } 50 | } 51 | 52 | /** WARNING: Drops all table on Upgrade! Use only during development. */ 53 | public static class DevOpenHelper extends OpenHelper { 54 | public DevOpenHelper(Context context, String name, CursorFactory factory) { 55 | super(context, name, factory); 56 | } 57 | 58 | @Override 59 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 60 | Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); 61 | dropAllTables(db, true); 62 | onCreate(db); 63 | } 64 | } 65 | 66 | public DaoMaster(SQLiteDatabase db) { 67 | super(db, SCHEMA_VERSION); 68 | registerDaoClass(KeepEntityDao.class); 69 | registerDaoClass(ToManyTarget2Dao.class); 70 | registerDaoClass(ToOneTarget2Dao.class); 71 | registerDaoClass(RelationSource2Dao.class); 72 | } 73 | 74 | public DaoSession newSession() { 75 | return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); 76 | } 77 | 78 | public DaoSession newSession(IdentityScopeType type) { 79 | return new DaoSession(db, type, daoConfigMap); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /DaoCore/src/de/greenrobot/dao/test/AbstractDaoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package de.greenrobot.dao.test; 18 | 19 | import java.lang.reflect.Method; 20 | 21 | import android.app.Application; 22 | import android.database.sqlite.SQLiteDatabase; 23 | import de.greenrobot.dao.AbstractDao; 24 | import de.greenrobot.dao.DaoLog; 25 | import de.greenrobot.dao.IdentityScope; 26 | import de.greenrobot.dao.Property; 27 | import de.greenrobot.dao.UnitTestDaoAccess; 28 | 29 | /** 30 | * Base class for DAO related testing. Prepares an in-memory DB and DAO. 31 | * 32 | * @author Markus 33 | * 34 | * @param 35 | * DAO class 36 | * @param 37 | * Entity type of the DAO 38 | * @param 39 | * Key type of the DAO 40 | */ 41 | public abstract class AbstractDaoTest, T, K> extends DbTest { 42 | 43 | protected final Class daoClass; 44 | protected D dao; 45 | protected UnitTestDaoAccess daoAccess; 46 | protected Property pkColumn; 47 | protected IdentityScope identityScopeForDao; 48 | 49 | public AbstractDaoTest(Class daoClass) { 50 | this(daoClass, true); 51 | } 52 | 53 | public AbstractDaoTest(Class daoClass, boolean inMemory) { 54 | super(inMemory); 55 | this.daoClass = daoClass; 56 | } 57 | 58 | public void setIdentityScopeBeforeSetUp(IdentityScope identityScope) { 59 | this.identityScopeForDao = identityScope; 60 | } 61 | 62 | @SuppressWarnings("unchecked") 63 | @Override 64 | protected void setUp() { 65 | super.setUp(); 66 | try { 67 | setUpTableForDao(); 68 | daoAccess = new UnitTestDaoAccess(db, (Class>) daoClass, identityScopeForDao); 69 | dao = (D) daoAccess.getDao(); 70 | } catch (Exception e) { 71 | throw new RuntimeException("Could not prepare DAO Test", e); 72 | } 73 | } 74 | 75 | protected void setUpTableForDao() throws Exception { 76 | try { 77 | Method createTableMethod = daoClass.getMethod("createTable", SQLiteDatabase.class, boolean.class); 78 | createTableMethod.invoke(null, db, false); 79 | } catch (NoSuchMethodException e) { 80 | DaoLog.i("No createTable method"); 81 | } 82 | } 83 | 84 | protected void clearIdentityScopeIfAny() { 85 | if (identityScopeForDao != null) { 86 | identityScopeForDao.clear(); 87 | DaoLog.d("Identity scope cleared"); 88 | } else { 89 | DaoLog.d("No identity scope to clear"); 90 | } 91 | } 92 | 93 | protected void logTableDump() { 94 | logTableDump(dao.getTablename()); 95 | } 96 | } -------------------------------------------------------------------------------- /PerformanceTestOrmLite/src/de/greenrobot/performance/ormlite/SimpleEntityNotNull.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.performance.ormlite; 2 | 3 | import com.j256.ormlite.field.DataType; 4 | import com.j256.ormlite.field.DatabaseField; 5 | import com.j256.ormlite.table.DatabaseTable; 6 | 7 | 8 | /** 9 | * Entity mapped to table SIMPLE_ENTITY_NOT_NULL (schema version 1). 10 | */ 11 | @DatabaseTable(tableName = "SIMPLE_ENTITY_NOT_NULL") 12 | public class SimpleEntityNotNull { 13 | 14 | @DatabaseField(id = true, columnName="_id") 15 | private long id; 16 | 17 | @DatabaseField(columnName="SIMPLE_BOOLEAN") 18 | private boolean simpleBoolean; 19 | @DatabaseField(columnName="SIMPLE_BYTE") 20 | private byte simpleByte; 21 | @DatabaseField(columnName="SIMPLE_SHORT") 22 | private short simpleShort; 23 | @DatabaseField(columnName="SIMPLE_INT") 24 | private int simpleInt; 25 | @DatabaseField(columnName="SIMPLE_LONG") 26 | private long simpleLong; 27 | @DatabaseField(columnName="SIMPLE_FLOAT") 28 | private float simpleFloat; 29 | @DatabaseField(columnName="SIMPLE_DOUBLE") 30 | private double simpleDouble; 31 | @DatabaseField(columnName="SIMPLE_STRING") 32 | private String simpleString; 33 | @DatabaseField(dataType=DataType.BYTE_ARRAY,columnName="SIMPLE_BYTE_ARRAY") 34 | private byte[] simpleByteArray; 35 | 36 | public long getId() { 37 | return id; 38 | } 39 | 40 | public void setId(long id) { 41 | this.id = id; 42 | } 43 | 44 | public boolean getSimpleBoolean() { 45 | return simpleBoolean; 46 | } 47 | 48 | public void setSimpleBoolean(boolean simpleBoolean) { 49 | this.simpleBoolean = simpleBoolean; 50 | } 51 | 52 | public byte getSimpleByte() { 53 | return simpleByte; 54 | } 55 | 56 | public void setSimpleByte(byte simpleByte) { 57 | this.simpleByte = simpleByte; 58 | } 59 | 60 | public short getSimpleShort() { 61 | return simpleShort; 62 | } 63 | 64 | public void setSimpleShort(short simpleShort) { 65 | this.simpleShort = simpleShort; 66 | } 67 | 68 | public int getSimpleInt() { 69 | return simpleInt; 70 | } 71 | 72 | public void setSimpleInt(int simpleInt) { 73 | this.simpleInt = simpleInt; 74 | } 75 | 76 | public long getSimpleLong() { 77 | return simpleLong; 78 | } 79 | 80 | public void setSimpleLong(long simpleLong) { 81 | this.simpleLong = simpleLong; 82 | } 83 | 84 | public float getSimpleFloat() { 85 | return simpleFloat; 86 | } 87 | 88 | public void setSimpleFloat(float simpleFloat) { 89 | this.simpleFloat = simpleFloat; 90 | } 91 | 92 | public double getSimpleDouble() { 93 | return simpleDouble; 94 | } 95 | 96 | public void setSimpleDouble(double simpleDouble) { 97 | this.simpleDouble = simpleDouble; 98 | } 99 | 100 | public String getSimpleString() { 101 | return simpleString; 102 | } 103 | 104 | public void setSimpleString(String simpleString) { 105 | this.simpleString = simpleString; 106 | } 107 | 108 | public byte[] getSimpleByteArray() { 109 | return simpleByteArray; 110 | } 111 | 112 | public void setSimpleByteArray(byte[] simpleByteArray) { 113 | this.simpleByteArray = simpleByteArray; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/TreeEntityTest.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest.entity; 2 | 3 | import android.app.Application; 4 | import de.greenrobot.dao.test.AbstractDaoSessionTest; 5 | import de.greenrobot.daotest.DaoMaster; 6 | import de.greenrobot.daotest.DaoSession; 7 | import de.greenrobot.daotest.TreeEntity; 8 | import de.greenrobot.daotest.TreeEntityDao; 9 | 10 | public class TreeEntityTest extends AbstractDaoSessionTest { 11 | 12 | private TreeEntityDao treeEntityDao; 13 | 14 | public TreeEntityTest() { 15 | super(DaoMaster.class); 16 | } 17 | 18 | @Override 19 | protected void setUp() { 20 | super.setUp(); 21 | treeEntityDao = daoSession.getTreeEntityDao(); 22 | } 23 | 24 | public void testNavigateTreeFromLeaf() { 25 | createTree(); 26 | daoSession.clear(); 27 | 28 | TreeEntity child1Child = treeEntityDao.load(101l); 29 | assertEquals(0, child1Child.getChildren().size()); 30 | 31 | TreeEntity child1 = child1Child.getParent(); 32 | assertEquals(11l, child1.getId().longValue()); 33 | assertEquals(1, child1.getChildren().size()); 34 | assertSame(child1Child, child1.getChildren().get(0)); 35 | 36 | TreeEntity root = child1.getParent(); 37 | assertEquals(1l, root.getId().longValue()); 38 | assertEquals(2, root.getChildren().size()); 39 | assertNull(root.getParent()); 40 | } 41 | 42 | public void testNavigateTreeFromMiddle() { 43 | createTree(); 44 | daoSession.clear(); 45 | 46 | TreeEntity child1 = treeEntityDao.load(11l); 47 | assertEquals(1, child1.getChildren().size()); 48 | TreeEntity child1Child = child1.getChildren().get(0); 49 | assertEquals(101, child1Child.getId().longValue()); 50 | assertEquals(0, child1Child.getChildren().size()); 51 | 52 | TreeEntity root = child1.getParent(); 53 | assertEquals(1l, root.getId().longValue()); 54 | assertEquals(2, root.getChildren().size()); 55 | assertNull(root.getParent()); 56 | } 57 | 58 | public void testNavigateTreeFromRoot() { 59 | createTree(); 60 | daoSession.clear(); 61 | 62 | TreeEntity root = treeEntityDao.load(1l); 63 | assertEquals(2, root.getChildren().size()); 64 | assertNull(root.getParent()); 65 | 66 | TreeEntity child1 = root.getChildren().get(0); 67 | TreeEntity child2 = root.getChildren().get(1); 68 | if (child1.getId() != 11l) { 69 | child1 = child2; 70 | child2 = root.getChildren().get(0); 71 | } 72 | 73 | assertSame(root, child1.getParent()); 74 | assertEquals(1, child1.getChildren().size()); 75 | TreeEntity child1Child = child1.getChildren().get(0); 76 | assertEquals(101, child1Child.getId().longValue()); 77 | assertEquals(0, child1Child.getChildren().size()); 78 | 79 | assertSame(root, child2.getParent()); 80 | assertEquals(0, child2.getChildren().size()); 81 | } 82 | 83 | private void createTree() { 84 | TreeEntity root = new TreeEntity(1l); 85 | TreeEntity child1 = new TreeEntity(11l); 86 | child1.setParent(root); 87 | TreeEntity child2 = new TreeEntity(12l); 88 | child2.setParent(root); 89 | TreeEntity child1Child = new TreeEntity(101l); 90 | child1Child.setParent(child1); 91 | treeEntityDao.insertInTx(root, child1, child2, child1Child); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /DaoTest/src/de/greenrobot/daotest/entity/AnActiveEntityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * This file is part of greenDAO Generator. 5 | * 6 | * greenDAO Generator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * greenDAO Generator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with greenDAO Generator. If not, see . 17 | */ 18 | package de.greenrobot.daotest.entity; 19 | 20 | import android.app.Application; 21 | import de.greenrobot.dao.DaoException; 22 | import de.greenrobot.dao.test.AbstractDaoSessionTest; 23 | import de.greenrobot.daotest.AnActiveEntity; 24 | import de.greenrobot.daotest.AnActiveEntityDao; 25 | import de.greenrobot.daotest.DaoMaster; 26 | import de.greenrobot.daotest.DaoSession; 27 | 28 | public class AnActiveEntityTest extends AbstractDaoSessionTest { 29 | 30 | 31 | private AnActiveEntityDao dao; 32 | 33 | public AnActiveEntityTest() { 34 | super(DaoMaster.class); 35 | } 36 | 37 | @Override 38 | protected void setUp() { 39 | super.setUp(); 40 | dao = daoSession.getAnActiveEntityDao(); 41 | } 42 | 43 | public void testThrowWhenDetached() { 44 | AnActiveEntity entity = new AnActiveEntity(); 45 | try { 46 | entity.delete(); 47 | fail("Should fail for detached entity"); 48 | } catch (DaoException e) { 49 | // OK, expected 50 | } 51 | try { 52 | entity.refresh(); 53 | fail("Should fail for detached entity"); 54 | } catch (DaoException e) { 55 | // OK, expected 56 | } 57 | try { 58 | entity.update(); 59 | fail("Should fail for detached entity"); 60 | } catch (DaoException e) { 61 | // OK, expected 62 | } 63 | } 64 | 65 | public void testActiveUpdate() { 66 | AnActiveEntity entity = new AnActiveEntity(1l); 67 | long rowId = dao.insert(entity); 68 | 69 | entity.setText("NEW"); 70 | entity.update(); 71 | 72 | daoSession.clear(); 73 | AnActiveEntity entity2 = dao.load(rowId); 74 | assertNotSame(entity, entity2); 75 | assertEquals("NEW", entity2.getText()); 76 | } 77 | 78 | 79 | public void testActiveRefresh() { 80 | AnActiveEntity entity = new AnActiveEntity(1l); 81 | dao.insert(entity); 82 | 83 | AnActiveEntity entity2 = new AnActiveEntity(1l); 84 | entity2.setText("NEW"); 85 | dao.update(entity2); 86 | 87 | entity.refresh(); 88 | assertEquals("NEW", entity.getText()); 89 | } 90 | 91 | public void testActiveDelete() { 92 | AnActiveEntity entity = new AnActiveEntity(1l); 93 | dao.insert(entity); 94 | 95 | entity.delete(); 96 | assertNull( dao.load(1l)); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /DaoExampleGenerator/src/de/greenrobot/daogenerator/gentest/ExampleDaoGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package de.greenrobot.daogenerator.gentest; 17 | 18 | import de.greenrobot.daogenerator.*; 19 | 20 | /** 21 | * Generates entities and DAOs for the example project DaoExample. 22 | * 23 | * Run it as a Java application (not Android). 24 | * 25 | * @author Markus 26 | */ 27 | public class ExampleDaoGenerator { 28 | 29 | public static void main(String[] args) throws Exception { 30 | Schema schema = new Schema(3, "de.greenrobot.daoexample"); 31 | 32 | addNote(schema); 33 | addCustomerOrder(schema); 34 | 35 | new DaoGenerator().generateAll(schema, "greenDAO/DaoExample/src-gen"); 36 | } 37 | 38 | private static void addNote(Schema schema) { 39 | Entity note = schema.addEntity("Note"); 40 | 41 | note.addIdProperty(); 42 | note.addStringProperty("text").notNull().addSetterAnnotation(new Annotation("test5", "key1", "value1")); 43 | note.addStringProperty("comment").addFieldAnnotation(new Annotation("JSONIgnore")); 44 | note.addDateProperty("date").addSetterAnnotation(new Annotation("Test", "key1", "value1")); 45 | note.addAnnotation(new Annotation("Test")); 46 | note.addAnnotation(new Annotation("Test2", "singleValueeee")); 47 | note.addAnnotation(new Annotation("Test3", "key1", "5", "key2","\"value2\"")); 48 | note.addAnnotation(new Annotation("Test4", "key1", null, "key2","\"value2\"")); 49 | note.addEnumProperty("gender", "NoteActivity.Gender", new Annotation("Test", "key1", "value1")).addImport("de.greenrobot.daoexample.NoteActivity"); 50 | note.addProperty(PropertyType.StringList, "userIds"); 51 | 52 | note.addEmptyConstructorAnnotation(new Annotation("Deprecated")); 53 | note.addFullConstructorAnnotation(new Annotation("Inject", "Context")); 54 | 55 | } 56 | 57 | private static void addCustomerOrder(Schema schema) { 58 | Entity customer = schema.addEntity("Customer"); 59 | customer.addIdProperty(); 60 | customer.addStringProperty("name").notNull(); 61 | 62 | Entity order = schema.addEntity("Order"); 63 | order.setTableName("ORDERS"); // "ORDER" is a reserved keyword 64 | order.addIdProperty(); 65 | Property orderDate = order.addDateProperty("date").getProperty(); 66 | Property customerId = order.addLongProperty("customerId").notNull().getProperty(); 67 | order.addToOne(customer, customerId); 68 | Property serializedCustomer = order.addProperty(PropertyType.ByteArray, "serializedCustomer").getProperty(); 69 | order.addSerializedProperty(serializedCustomer, "customer2", "Customer"); 70 | 71 | ToMany customerToOrders = customer.addToMany(order, customerId); 72 | customerToOrders.setName("orders"); 73 | customerToOrders.orderAsc(orderDate); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest2/dao/KeepEntityDao.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest2.dao; 2 | 3 | import android.database.Cursor; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteStatement; 6 | 7 | import de.greenrobot.dao.AbstractDao; 8 | import de.greenrobot.dao.DaoConfig; 9 | import de.greenrobot.dao.Property; 10 | 11 | import de.greenrobot.daotest2.KeepEntity; 12 | 13 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 14 | /** 15 | * DAO for table KEEP_ENTITY. 16 | */ 17 | public class KeepEntityDao extends AbstractDao { 18 | 19 | public static final String TABLENAME = "KEEP_ENTITY"; 20 | 21 | /** 22 | * Properties of entity KeepEntity.
23 | * Can be used for QueryBuilder and for referencing column names. 24 | */ 25 | public static class Properties { 26 | public final static Property Id = new Property(0, Long.class, "id", true, "_id"); 27 | }; 28 | 29 | 30 | public KeepEntityDao(DaoConfig config) { 31 | super(config); 32 | } 33 | 34 | public KeepEntityDao(DaoConfig config, DaoSession daoSession) { 35 | super(config, daoSession); 36 | } 37 | 38 | /** Creates the underlying database table. */ 39 | public static void createTable(SQLiteDatabase db, boolean ifNotExists) { 40 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; 41 | db.execSQL("CREATE TABLE " + constraint + "'KEEP_ENTITY' (" + // 42 | "'_id' INTEGER PRIMARY KEY );"); // 0: id 43 | } 44 | 45 | /** Drops the underlying database table. */ 46 | public static void dropTable(SQLiteDatabase db, boolean ifExists) { 47 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'KEEP_ENTITY'"; 48 | db.execSQL(sql); 49 | } 50 | 51 | /** @inheritdoc */ 52 | @Override 53 | protected void bindValues(SQLiteStatement stmt, KeepEntity entity) { 54 | stmt.clearBindings(); 55 | 56 | Long id = entity.getId(); 57 | if (id != null) { 58 | stmt.bindLong(1, id); 59 | } 60 | } 61 | 62 | /** @inheritdoc */ 63 | @Override 64 | public Long readKey(Cursor cursor, int offset) { 65 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); 66 | } 67 | 68 | /** @inheritdoc */ 69 | @Override 70 | public KeepEntity readEntity(Cursor cursor, int offset) { 71 | KeepEntity entity = new KeepEntity( // 72 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0) // id 73 | ); 74 | return entity; 75 | } 76 | 77 | /** @inheritdoc */ 78 | @Override 79 | public void readEntity(Cursor cursor, KeepEntity entity, int offset) { 80 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); 81 | } 82 | 83 | /** @inheritdoc */ 84 | @Override 85 | protected Long updateKeyAfterInsert(KeepEntity entity, long rowId) { 86 | entity.setId(rowId); 87 | return rowId; 88 | } 89 | 90 | /** @inheritdoc */ 91 | @Override 92 | public Long getKey(KeepEntity entity) { 93 | if(entity != null) { 94 | return entity.getId(); 95 | } else { 96 | return null; 97 | } 98 | } 99 | 100 | /** @inheritdoc */ 101 | @Override 102 | protected boolean isEntityUpdateable() { 103 | return true; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest/SimpleEntity.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 4 | /** 5 | * Entity mapped to table SIMPLE_ENTITY. 6 | */ 7 | public class SimpleEntity { 8 | 9 | private Long id; 10 | private Boolean simpleBoolean; 11 | private Byte simpleByte; 12 | private Short simpleShort; 13 | private Integer simpleInt; 14 | private Long simpleLong; 15 | private Float simpleFloat; 16 | private Double simpleDouble; 17 | private String simpleString; 18 | private byte[] simpleByteArray; 19 | 20 | public SimpleEntity() { 21 | } 22 | 23 | public SimpleEntity(Long id) { 24 | this.id = id; 25 | } 26 | 27 | public SimpleEntity(Long id, Boolean simpleBoolean, Byte simpleByte, Short simpleShort, Integer simpleInt, Long simpleLong, Float simpleFloat, Double simpleDouble, String simpleString, byte[] simpleByteArray) { 28 | this.id = id; 29 | this.simpleBoolean = simpleBoolean; 30 | this.simpleByte = simpleByte; 31 | this.simpleShort = simpleShort; 32 | this.simpleInt = simpleInt; 33 | this.simpleLong = simpleLong; 34 | this.simpleFloat = simpleFloat; 35 | this.simpleDouble = simpleDouble; 36 | this.simpleString = simpleString; 37 | this.simpleByteArray = simpleByteArray; 38 | } 39 | 40 | public Long getId() { 41 | return id; 42 | } 43 | 44 | public void setId(Long id) { 45 | this.id = id; 46 | } 47 | 48 | public Boolean getSimpleBoolean() { 49 | return simpleBoolean; 50 | } 51 | 52 | public void setSimpleBoolean(Boolean simpleBoolean) { 53 | this.simpleBoolean = simpleBoolean; 54 | } 55 | 56 | public Byte getSimpleByte() { 57 | return simpleByte; 58 | } 59 | 60 | public void setSimpleByte(Byte simpleByte) { 61 | this.simpleByte = simpleByte; 62 | } 63 | 64 | public Short getSimpleShort() { 65 | return simpleShort; 66 | } 67 | 68 | public void setSimpleShort(Short simpleShort) { 69 | this.simpleShort = simpleShort; 70 | } 71 | 72 | public Integer getSimpleInt() { 73 | return simpleInt; 74 | } 75 | 76 | public void setSimpleInt(Integer simpleInt) { 77 | this.simpleInt = simpleInt; 78 | } 79 | 80 | public Long getSimpleLong() { 81 | return simpleLong; 82 | } 83 | 84 | public void setSimpleLong(Long simpleLong) { 85 | this.simpleLong = simpleLong; 86 | } 87 | 88 | public Float getSimpleFloat() { 89 | return simpleFloat; 90 | } 91 | 92 | public void setSimpleFloat(Float simpleFloat) { 93 | this.simpleFloat = simpleFloat; 94 | } 95 | 96 | public Double getSimpleDouble() { 97 | return simpleDouble; 98 | } 99 | 100 | public void setSimpleDouble(Double simpleDouble) { 101 | this.simpleDouble = simpleDouble; 102 | } 103 | 104 | public String getSimpleString() { 105 | return simpleString; 106 | } 107 | 108 | public void setSimpleString(String simpleString) { 109 | this.simpleString = simpleString; 110 | } 111 | 112 | public byte[] getSimpleByteArray() { 113 | return simpleByteArray; 114 | } 115 | 116 | public void setSimpleByteArray(byte[] simpleByteArray) { 117 | this.simpleByteArray = simpleByteArray; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /DaoTest/src-gen/de/greenrobot/daotest2/dao/DaoSession.java: -------------------------------------------------------------------------------- 1 | package de.greenrobot.daotest2.dao; 2 | 3 | import android.database.sqlite.SQLiteDatabase; 4 | 5 | import java.util.Map; 6 | 7 | import de.greenrobot.dao.AbstractDao; 8 | import de.greenrobot.dao.DaoConfig; 9 | import de.greenrobot.dao.AbstractDaoSession; 10 | import de.greenrobot.dao.IdentityScopeType; 11 | 12 | import de.greenrobot.daotest2.KeepEntity; 13 | import de.greenrobot.daotest2.ToManyTarget2; 14 | import de.greenrobot.daotest2.to1_specialentity.ToOneTarget2; 15 | import de.greenrobot.daotest2.specialentity.RelationSource2; 16 | 17 | import de.greenrobot.daotest2.dao.KeepEntityDao; 18 | import de.greenrobot.daotest2.dao.ToManyTarget2Dao; 19 | import de.greenrobot.daotest2.to1_specialdao.ToOneTarget2Dao; 20 | import de.greenrobot.daotest2.specialdao.RelationSource2Dao; 21 | 22 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 23 | 24 | /** 25 | * {@inheritDoc} 26 | * 27 | * @see de.greenrobot.dao.AbstractDaoSession 28 | */ 29 | public class DaoSession extends AbstractDaoSession { 30 | 31 | private final DaoConfig keepEntityDaoConfig; 32 | private final DaoConfig toManyTarget2DaoConfig; 33 | private final DaoConfig toOneTarget2DaoConfig; 34 | private final DaoConfig relationSource2DaoConfig; 35 | 36 | private final KeepEntityDao keepEntityDao; 37 | private final ToManyTarget2Dao toManyTarget2Dao; 38 | private final ToOneTarget2Dao toOneTarget2Dao; 39 | private final RelationSource2Dao relationSource2Dao; 40 | 41 | public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map>, DaoConfig> 42 | daoConfigMap) { 43 | super(db); 44 | 45 | keepEntityDaoConfig = daoConfigMap.get(KeepEntityDao.class).clone(); 46 | keepEntityDaoConfig.initIdentityScope(type); 47 | 48 | toManyTarget2DaoConfig = daoConfigMap.get(ToManyTarget2Dao.class).clone(); 49 | toManyTarget2DaoConfig.initIdentityScope(type); 50 | 51 | toOneTarget2DaoConfig = daoConfigMap.get(ToOneTarget2Dao.class).clone(); 52 | toOneTarget2DaoConfig.initIdentityScope(type); 53 | 54 | relationSource2DaoConfig = daoConfigMap.get(RelationSource2Dao.class).clone(); 55 | relationSource2DaoConfig.initIdentityScope(type); 56 | 57 | keepEntityDao = new KeepEntityDao(keepEntityDaoConfig, this); 58 | toManyTarget2Dao = new ToManyTarget2Dao(toManyTarget2DaoConfig, this); 59 | toOneTarget2Dao = new ToOneTarget2Dao(toOneTarget2DaoConfig, this); 60 | relationSource2Dao = new RelationSource2Dao(relationSource2DaoConfig, this); 61 | 62 | registerDao(KeepEntity.class, keepEntityDao); 63 | registerDao(ToManyTarget2.class, toManyTarget2Dao); 64 | registerDao(ToOneTarget2.class, toOneTarget2Dao); 65 | registerDao(RelationSource2.class, relationSource2Dao); 66 | } 67 | 68 | public void clear() { 69 | keepEntityDaoConfig.getIdentityScope().clear(); 70 | toManyTarget2DaoConfig.getIdentityScope().clear(); 71 | toOneTarget2DaoConfig.getIdentityScope().clear(); 72 | relationSource2DaoConfig.getIdentityScope().clear(); 73 | } 74 | 75 | public KeepEntityDao getKeepEntityDao() { 76 | return keepEntityDao; 77 | } 78 | 79 | public ToManyTarget2Dao getToManyTarget2Dao() { 80 | return toManyTarget2Dao; 81 | } 82 | 83 | public ToOneTarget2Dao getToOneTarget2Dao() { 84 | return toOneTarget2Dao; 85 | } 86 | 87 | public RelationSource2Dao getRelationSource2Dao() { 88 | return relationSource2Dao; 89 | } 90 | 91 | } 92 | --------------------------------------------------------------------------------