Comments (4)
Ahh, got it.
Unfortunately, the update()
method is an all-in method so it will consider all columns. The only other solution is an updateBuilder()
, something like this:
final UpdateBuilderUser, Long> builder = userDao.updateBuilder();
builder
.updateColumnValue("address", "new address")
.where().idEq(1);
builder.update();
Regarding the column names: yes, you should probably define constants for them, either alongside the main User.java class
or inside it as an inner class.
Finally, you surely can consider an OAS3 specification which you can use just for the models.
from ormlite-jdbc.
Unsure what you really mean... Can you provide an example to showcase what you want?
from ormlite-jdbc.
I have code like this:
class User{
Long id;
String name;
String password;
String address;
}
....
Dao<User,Long> userDao = ....
....
User user = new User();
user.id=1;
user.name="test";
user.password="test";
user.address="test";
userDao.create(user);
and I want to update user's address where id=1, I want do this:
User user = new User();
user.id=1;
user.address="new address";
userDao.update(user);
and then, it throw exception that some column can not be null.
I know it hava UpdateBuilder, but UpdateBuilder need column name, and I don't think update method should care column name when I already have a POJO.
from ormlite-jdbc.
Another way to do this is to get the user from the database and then update it.
User user = userDao.queryForId(1);
user.address = "new address";
userDao.update(user);
That's how it is supposed to work. Or, as @noordawod said, you should use the UpdateBuilder
.
from ormlite-jdbc.
Related Issues (20)
- Column Sizes Shrinking HOT 5
- Succeed use for SQLite in Windows, but failed in Mac. HOT 3
- Compatibility with Java 9. HOT 7
- UnsatisfiedLinkError: couldn't find "libsqlitejdbc.so" HOT 4
- SQLCipher in Ormlite SQLITE DB JDBC
- The ODBC database type should be deprecated/removed
- How to connect two entities in different tables HOT 6
- `DATABASE_URL == null` should throw an exception HOT 1
- Asynchronous JDBC HOT 5
- Duplicate package names in core and jdbc jars HOT 1
- broken links in ยง7 (example code) of documentation HOT 1
- NullPointerException when use JdbcSingleConnectionSource HOT 1
- @DatabaseField(foreign = true) doesn't generate foreign key constraints HOT 3
- [MariaDbDatabaseType] isCreateIndexIfNotExistsSupported returns false although the feature is supported
- Problems to detect existing tables with mariadb-java-client 3.x.y
- Support for SQL query index hints. HOT 1
- Statement getGeneratedKeys HOT 6
- `generatedId` field not supported since Xerial SQLite driver 3.43.0.0 HOT 1
- Security vulnerability - SQL injection #147
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ormlite-jdbc.