Comments (9)
can you show me your oauth_client_details table's schema?
from spring-data-mybatis.
create table sql
from spring-data-mybatis.
Here it is (https://github.com/Baeldung/spring-security-oauth/blob/master/spring-security-oauth-server/src/main/resources/schema.sql):
DROP TABLE if EXISTS oauth_client_details;
CREATE TABLE oauth_client_details (
client_id VARCHAR(255) PRIMARY KEY,
resource_ids VARCHAR(255),
client_secret VARCHAR(255),
scope VARCHAR(255),
authorized_grant_types VARCHAR(255),
web_server_redirect_uri VARCHAR(255),
authorities VARCHAR(255),
access_token_validity INTEGER,
refresh_token_validity INTEGER,
additional_information VARCHAR(4096),
autoapprove VARCHAR(255)
);
I am trying every possible explained way on stackoverflow to enable mybatis logging, none of them work. I use slf4j and this is my application.yml
configuration
logging:
pattern:
console: "%msg%n"
level:
com: INFO
org.springframework.security: DEBUG
org.springframework.web: INFO
guru.springframework.controllers: INFO
# SqlMap logging configuration.
com.ibatis: DEBUG
com.ibatis.common.jdbc.SimpleDataSource: DEBUG
com.ibatis.common.jdbc.ScriptRunner: DEBUG
com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate: DEBUG
java.sql: DEBUG
java.sql.Connection: DEBUG
java.sql.Statement: DEBUG
java.sql.PreparedStatement: DEBUG
java.sql.ResultSet: DEBUG
from spring-data-mybatis.
if you want to print sql, you need to add property :
logging:
level:
{OAuthClient's package name}: debug
from spring-data-mybatis.
I have the following :
==> Preparing: update oauth_client_details SET authorized_grant_types=?,access_token_validity=?,additional_information=?,client_secret=?,autoapprove=?,resource_ids=?,web_server_redirect_uri=?,authorities=?,refresh_token_validity=?,scope=? where client_id=?
==> Parameters: authorization_code,refresh_token(String), 1800(Integer), {"companyId":1,"companyName":"Toto"}(String), toto(String), true(Boolean), toto/api(String), http://localhost:8080,http://dev:31735(String), 4(String), 3600(Integer), read,write,trust(String), bo(String)
<== Updates: 0
Started Application in 52.102 seconds (JVM running for 54.068)
Apparently it's trying to UPDATE instead of INSERT.
from spring-data-mybatis.
have a try :
public class OAuthClient implements ClientDetails , Persistable<String>
from spring-data-mybatis.
Still trying to do update instead of insert.
I finally got it, it happen in SimpleMybatisRepository.java#L67
if (entityInformation.isNew(entity)) {}
The isNew()
method normally check if the id is not null to consider it new.
In my case, the oauth client needs to have the id setten before the insertion.
Thanks to your indication, I have overriden the isNew
method in OAuthClient
.
I also added a creation_datetime
field to the table oauth_client_details
.
I am checking if the creationDateTime value is null to check if it's a new entity.
The creation_datetime
field is not updated on insert but it will in 1.0.6 (see #37) so this will later work.
==> Preparing:
insert into oauth_client_details(authorized_grant_types,access_token_validity,additional_information,active,client_secret,creation_datetime,autoapprove,modification_datetime,resource_ids,web_server_redirect_uri,authorities,refresh_token_validity,scope,version) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)
==> Parameters: authorization_code,refresh_token(String), 1800(Integer), {"companyId":1,"companyName":"test Ltd"}(String), true(Boolean), $2a$10$twu1rKVcbqFLyilgAEz3g.B1S5oXGqzOHAyFyPrvamOykjGjC/nnu(String), null, true(Boolean), null, testgroup/api(String), http://localhost:8080,http://dev:31735(String), ROLE_CLIENT(String), 3600(Integer), read,write,trust(String), 1(Long)
Another problem was the ID couldn't be inserted throwing another exception :
org.mariadb.jdbc.internal.util.dao.QueryException: Field 'client_id' doesn't have a default value
I guessed this had something to do with :
enum GenerationType {
AUTO,
SEQUENCE,
IDENTITY,
ASSIGNATION,
UUID, TABLE, DISTRIBUTED;
}
I switch to @Id(strategy = ASSIGNATION)
annotation and it worked!
I'll wait for the documentation to understand each use case.
from spring-data-mybatis.
You are very professional!
from spring-data-mybatis.
You made my xmas with this module ! Thank you so much.
from spring-data-mybatis.
Related Issues (20)
- 这个项目还会支持最新版的spring boot吗 HOT 1
- complex composite id
- Related queries support sorting
- @ElementCollection support
- 后续有什么计划吗
- 请问啥时发布新版本
- @Convert 注解似乎还不支持
- 中文说明中spring-boot的mapper文件配置错误
- 是否支持批量新增、修改
- Table names support uniform prefixes
- Join table supports uniform table prefix
- The official website document is gone. 文档没了
- change mapper.xml's namespace reference Repository but not DO #feature
- base on branch 3.x, I build it successful. Can I take a pull request? HOT 1
- 3.x支持多数据源么
- Is this repo still being maintained? HOT 1
- Multi-tenant support
- can support @GeneratedValue? HOT 2
- MybatisEntityManagerAutoConfiguration not running
- Multi-tenant problems
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 spring-data-mybatis.