Skip to content Skip to sidebar Skip to footer

Orm Lite Throws Error When Creating Tables Containing Multi Level Foreign Key

I'm getting this error on ORM Lite when creating table ActivityLog : 10-23 04:06:32.255: E/com.timelord.dao.DatabaseHelper(1487): Caused by: java.sql.SQLException: ORMLite can't s

Solution 1:

No, ORMLite can handle multi level foreign keys without any issues. The problem is that you cannot mix @DatabaseField and @DatabaseFieldForeign annotations. What you want is:

@DatabaseField(canBeNull =false, foreign=true)
private Activity activity;

Or, if you want to use the smaller annotations which run faster under Android:

@DatabaseFieldSimple(canBeNull = false)
@DatabaseFieldForeign(foreign = true)

Either you use just the @DatabaseField or @DatabaseFieldSimple and the other @DatabaseField... annotations. Here are the docs for @DatabaseFieldSimple:

http://ormlite.com/javadoc/ormlite-core/com/j256/ormlite/field/DatabaseFieldSimple.html

Post a Comment for "Orm Lite Throws Error When Creating Tables Containing Multi Level Foreign Key"