Giter Club home page Giter Club logo

Comments (9)

easybest avatar easybest commented on July 20, 2024

can you show me your oauth_client_details table's schema?

from spring-data-mybatis.

easybest avatar easybest commented on July 20, 2024

create table sql

from spring-data-mybatis.

kopax avatar kopax commented on July 20, 2024

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.

easybest avatar easybest commented on July 20, 2024

if you want to print sql, you need to add property :

logging:
  level:
    {OAuthClient's package name}: debug

from spring-data-mybatis.

kopax avatar kopax commented on July 20, 2024

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.

easybest avatar easybest commented on July 20, 2024

have a try :

public class OAuthClient implements ClientDetails , Persistable<String>

from spring-data-mybatis.

kopax avatar kopax commented on July 20, 2024

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.

easybest avatar easybest commented on July 20, 2024

You are very professional!

from spring-data-mybatis.

kopax avatar kopax commented on July 20, 2024

You made my xmas with this module ! Thank you so much.

from spring-data-mybatis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.