android


OrmLite can create table successfully but cause error after insert a record


In my project I used OrmLite to create a table named OrderItem, in logcat it create table successfully but when I try to insert a record it show an exception. I would like to know why this is happening? Please my logcat.
Thanks
After create OrderItem
09-12 07:30:13.075: I/TableUtils(22428): creating table 'OrderItem'
09-12 07:30:13.085: I/TableUtils(22428): executed create table statement changed 1 rows: CREATE TABLE `OrderItem` (`custom_taste` VARCHAR , `order_id` INTEGER , `name` VARCHAR , `id` INTEGER PRIMARY KEY AUTOINCREMENT , `food_id` INTEGER , `quantity` INTEGER )
After insert a record to OrderItem it show food_id column not found. In above logcat food_id column is created.
09-12 07:32:00.885: E/SQLiteLog(22428): (1) table OrderItem has no column named food_id
09-12 07:32:00.905: W/System.err(22428): java.sql.SQLException: Unable to run insert stmt on object com.expresspos.mm.object.OrderItem#40ddbdd8: INSERT INTO `OrderItem` (`custom_taste` ,`order_id` ,`name` ,`food_id` ,`quantity` ) VALUES (?,?,?,?,?)
While I am waiting for somebody's answer, I searched some solution to my qestion. This link is helpful https://groups.google.com/forum/#!topic/ormlite-android/k-i1MnaL-aQ.
Here is my solution,
// some set of alter table statements to tweak the schema
orderItemDao.executeRaw("ALTER TABLE `OrderItem` ADD COLUMN food_id INTEGER DEFAULT 0;");
I didn't think about that I need to alter OrderItem table when adding a column. I have to alter table because that database I have preferred is already been created.
Thanks

Related Links

Use HC-06 Bluetooth Chip With PIC16F887?
How to solve this kind of Android ANR(system_server first process)?
How to include a .so library and .c files in Android Studio 1.5
Assign value to a variable in a string query at run time
Android: EditText input validation
Which directory is secure to save the data
ActionBar won't remove
Gradle finished with non-zero exit value 2?
Which values to update to in android studio
Activity Reload every time
Android Studio - saving user data
How to use Android proguard only with the optimize function
Creating a Serializable ArrayMap
Adding Intent Filter using manifest merger in Unity3d
Ionic Framework Build for IOS on El Capitan - Build Error (GCC?)
Android Setting Alarm from Fragment

Categories

HOME
javacc
entity-framework-core
code-coverage
data-visualization
trac
discrete-mathematics
qpython
fabric.io
github-enterprise
angular-dart
supervisor
libusb
http-post
coin3d
event-sourcing
alpacajs
searchview
identity-management
selinux
blade
springfox
question2answer
easeljs
object-storage
scriptella
vex
zend-debugger
hibernate-validator
autolisp
contacts
vue-chartjs
pdw-file-browser
searchkit
reason
xcode7.3
openalpr
nohup
mcustomscrollbar
httr
dynamic-linq
lampp
tinymce-3
openblas
boxing
android-testing
simplepie
atlas
vulcanize
model-associations
scaffolding
shopping
ikiwiki
thread-sleep
kendo-upload
jparsec
asyncdisplaykit
relativelayout
libvlc
atan2
inf
oracle-spatial
flock
include-guards
coda
lasso
packet-sniffers
angular-gettext
pseudo-class
metatrader5
easyrtc
machine-instruction
psr-4
linkedin-jsapi
unix-socket
cuba
clickbank
xmltodict
beaker-testing
observium
kaleidoscope
booksleeve
nokia-s40
boost-msm
adobe-media-server
urlrewriter
luabind
convention
procedures
umra
jqueryform
binomial-heap
ajax-polling
scrollbars
sifr
build-environment
windows-identity
ifilter
leader
wspbuilder

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App