how to update record ignore id in mybatis and postgresql
Options
varshadusa01
Member, ALL USERS Posts: 3 New Contributor
in Security
Now I am using mybatis to update PostgreSQL 13 record, I want to using user id to update apple purchase prouct id in user table, this is my code:
Users users = new Users();
users.setId(payTransactionRecord.getUserId());
users.setAppleIapProductId(productId);
I give the user entity id and product id, update product id by using user id. this is the update execute code using mybatis:
public int updateByPrimaryKey(Users user) {
UsersExample example = new UsersExample();
UsersExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(user.getId());
return userMapper.updateByExampleSelective(user,example);
}
but the mybatis geneate the sql like this cause error:
Caused by: org.springframework.jdbc.BadSqlGrammarException:
### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: column "id" can only be updated to DEFAULT
Detail: Column "id" is an identity column defined as GENERATED ALWAYS.
### The error may exist in class path resource [mybatis/mapper/dolphin/UsersMapper.xml]
### The error may involve com.dolphin.soa.post.dao.UsersMapper.updateByExampleSelective-Inline
### The error occurred while setting parameters
### SQL: UPDATE users SET id = ?, apple_iap_product_id = ? WHERE (id = ?)
### Cause: org.postgresql.util.PSQLException: ERROR: column "id" can only be updated to DEFAULT
Detail: Column "id" is an identity column defined as GENERATED ALWAYS.
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: column "id" can only be updated to DEFAULT
Detail: Column "id" is an identity column defined as GENERATED ALWAYS.
what should I do to fix it?
Tagged:
0
Categories
- All Categories
- 2.3K Anaplan Community
- Academy
- Anaplan Talent Builder
- Model Design Course
- The Anaplan Way
- Archive
- 2 Idea exchange
- 62 Enterprise Scale
- 1.1K Extensibility
- 21 Intelligence
- 1.6K Planning & Modeling
- 331 Security
- Community Connections
- Connections
- Experiences
- Groups
- Personas
- Employees
- CS Toolkit
- Customer Care Center
- Forums
- Academy & Training
- Community Feedback & Updates
- Japan
- Anaplan Community Japan
- Anaplan Community Japan Knowledge Base
- HyperCare Japan
- JP-Central
- Support-Japanese
- Partners
- Partner Leadership Council
- Partner Product Council
- 724 Platform
- Anapedia
- App Hub
- Centers Of Excellence
- Extensions
- Planual
- Platform Updates
- 724 User Experience
- Profile Builder
- Resources
- Anaplan Advocates
- Anaplan Live!
- Community
- Community Advancement
- Community Connections
- Partner Program
- The Official Master Anaplanner Program
- Videos
- Welcome to the Anaplan Community!
- Success Central
- Support
- Case Portal Link
- Common Support Questions
- HyperCare Redirect
- Known Issues and Workarounds
- Support test page
- SupportFAQ
- Survey
- 2 Training Day Takeaways