onurciner / OHibernate

SQLite Connection for Android. ORM tool for Android devices. First ORM with Geometric-Spatial data support for Android operating systems.
http://www.onurciner.com
14 stars 5 forks source link

Problem on table creation #3

Open AlexeyZatsepin opened 7 years ago

AlexeyZatsepin commented 7 years ago

I have such error when try this ORM:

java.lang.IndexOutOfBoundsException: Index: 4, Size: 4 at java.util.ArrayList.get(ArrayList.java:411) at com.onurciner.OHibernate.tableCreate(OHibernate.java:521) at com.onurciner.OHibernate.engine(OHibernate.java:432) at com.onurciner.OHibernate.insert(OHibernate.java:626)

my model:

@Entity(TABLE_NAME = "book", TABLE_OPERATION = Entity.TABLE_OPERATION_TYPE.DROP_AND_CREATE) public class Book{

@Id(PRIMARY_KEY_AUTOINCREMENT = true)
@Column(NAME="id")
private long id;
private String author;
private String title;
private int pagesCount;
private int bookId;

init:

private OHibernate bookDao = new OHibernate<>(Book.class);

public static final String DATABASE_EXTERNAL = Environment.getExternalStorageDirectory().getPath(); 
public static final String DATABASE_SUB = "/folderName/";
public static final String DATABASE_DB_PATH = DATABASE_EXTERNAL + DATABASE_SUB;
public static final String DATABASE_DATA_NAME = "databaseName.sqlite";

@Override
public void onCreate() {
    super.onCreate();
    OHibernateConfig.DB_PATH = DATABASE_DB_PATH; // DATABASE PATH
    OHibernateConfig.DB_NAME = DATABASE_DATA_NAME; // DATABASE NAME
}

onurciner commented 7 years ago

Hello. SQLite does not provide primary key length long support. You should use Integer.

@Id(PRIMARY_KEY_AUTOINCREMENT = true)
private Integer id;
private String author;
private String title;
private int pagesCount;
private int bookId;

It will work this way...

AlexeyZatsepin commented 7 years ago

Thanks, but now I have new exception. I looked through other issues and found that version 1.0.9 must solve this problem, but it doesn't

java.lang.UnsatisfiedLinkError: No implementation found for void jsqlite.Database.internal_init() (tried Java_jsqlite_Database_internal_1init and Java_jsqlite_Database_internal_1init__)