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

Code for android that would use a compass to point to a specific Longatude and Latatude?
implementing YouTube API v3 in ViewPager Android
Cannot find symbol class on Butter Knife generated code
java.lang.IllegalStateException: Layout state should be one of 100 but it is 10
Adding same views to RelativeLayout multiple times
How to use Observables, RxJava and Android to access a Webapi?
Create a transaction to update multiple places in Firebase Database
Notification does not displayed on wear, but displayed on hand held
Android emulator resolution issue after updating android sdk tool
IndexOutOfBoundsException when trying to populate data in recyclerview from two json arrays in a one json object
Count child nodes and show on parent node in Android Expandable ListView
Is it possible to set default transition animation for all application in AOSP?
Align menu item at Navigation to the right side in android
Recycler view only updating first visible position with onBind code?
Most efficient method of creating a local notification system with Firebase
Dagger 2: How properly to reuse dependency - how to design components and scopes?

Categories

HOME
facebook-oauth
linkedin
ng-idle
pyqt
can
dojo
visual-studio-emulator
rcloud
xcodebuild
nancy
selectize.js
entitymanager
template-engine
lilypond
imagemap
postscript
visual-studio-extensions
easeljs
displaytag
jquery-callback
comparator
gmock
data.stackexchange.com
google-cloud-print
shared
ms-access-web-app
fractions
send
installscript
processwire
docfx
railstutorial.org
typesafe-config
ogc
placeholder
facebook-social-plugins
x++
plan-9
openrasta
jquery-ui-draggable
spring-integration-sftp
page-replacement
arq
er-diagram
rackspace-cloud
cmp
rmongo
cronexpression
actor-platform
lrs
jodd
drawstring
jtwig
stream-processing
lua-telegram-bot
gcloud-ruby
findfirst
user-management
concept-insights
decimalformat
gocql
poppler
mod-proxy
jsvc
ansi
git-ftp
android-broadcast
bcache
procedural-programming
delayed-execution
filesplitting
structuremap3
xml-namespaces
c++builder-xe5
isqlquery
scringo
facebook-timeline
dolby-audio-api
twisted.web
rmiregistry
apache-whirr
window-decoration
luabind
node-redis
saxparseexception
winmain
mysql-error-1205
multiplatform
quotation-marks
inline-formset
socketserver
maven-1
easyb
mathematical-notation
asynchronous-wcf-call
xpsdocument
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