jcasbin / hibernate-adapter

Hibernete adapter for Casbin
https://github.com/casbin/jcasbin
Apache License 2.0
2 stars 6 forks source link

Datasource #5

Closed uPagge closed 3 years ago

uPagge commented 3 years ago

Adapter adapter = new HibernateAdapter(DRIVER, URL, USERNAME, PASSWORD, true);

Why not make the constructor accept a Datasource?

hsluoyz commented 3 years ago

@uPagge thanks for the advice!

@shy1st I think we can add a constructor for datasource arg too like the jdbc-adapter: https://github.com/jcasbin/jdbc-adapter

shy1st commented 3 years ago

@uPagge Excuse me, do you want this construction method? 捕获

uPagge commented 3 years ago

Yes that would be great

hsluoyz commented 3 years ago

@uPagge we are not very clear about how to implement sucha constructor, can you explain a little? Or even a PR would be great!

uPagge commented 3 years ago

Unfortunately I'm not that good: D

But I know where it is possible to spy on. Liquibase uses this, but not in the constructor is true. Perhaps the sources of Liquibase will help you understand.

изображение

shy1st commented 3 years ago

Sorry, we can get URL, driver and user name through datasource, but we can't get password. Can you provide password in the construction method? Or do you have any other ideas? @uPagge

shy1st commented 3 years ago

@uPagge Maybe the ConnectionProvider can set the datasource, but how to build SessionFactory through ConnectionProvider is a problem.May I ask you what is your idea?

uPagge commented 3 years ago

Well, my idea is that in the world of spring boot applications, database connection for libraries compatible with spring happens through this very datasource. Unfortunately, I do not know how to do this, and therefore I cannot tell. Just suggested an idea for improving convenience))

shy1st commented 3 years ago

@fangzhengjin Excuse me, may I ask you your idea?

fangzhengjin commented 3 years ago

@uPagge Are you using casbin in the spring boot ?

fangzhengjin commented 3 years ago

@fangzhengjin Excuse me, may I ask you your idea?

I think we can set the data source through the hibernate.connection.datasource configuration. see: database-connectionprovider-datasource

shy1st commented 3 years ago

@fangzhengjin Thank you for your advice!

hsluoyz commented 3 years ago

@shy1st plz make a new release on both Maven and GitHub.