Comments (6)
HI @Juchar
How many environments do you have in your App?
In terms of mapper injection, this:
@Inject
@Environment("env1")
UserMapper userMapper;
Is not so different from this:
@Inject
@Named("env1")
UserMapper userMapper;
And in terms of the producer, this is not a big deal:
@Produces
@Named("env1")
@SessionFactoryProvider
public SqlSessionFactory produceFactory1() {
return produceFactory("env1");
}
@Produces
@Named("env2")
@SessionFactoryProvider
public SqlSessionFactory produceFactory2() {
return produceFactory("env2");
}
You can also use your own Qualifier annotation, as soon as you use a producer method per Environment.
I don't know your implementation details but I suppose there are few environments. But if you have so many environments (something like more than 10) then it is a different story, but Environments are static anyway so I don't see the use case but please elaborate more to continue the discussion.
Thanks.
from cdi.
@hazendaz what do you think about this issue?
from cdi.
Not sure the benefit here. I generally have my environmental information separated from the code so I'm basically only injecting in what I actually need for any given environment with a system property to tell me what specific file to read and use. That may not be entirely cloud ready solution but not sure about using it in this way. Unfortunately I have not gotten far enough at my day job to finally start using mybatis-cdi over our home grown solution due to changing priorities and the code being given off to another team I only occassionally get to help. I might have a better opinion in a couple months given I've recently been pulled back in a bit.
from cdi.
And I must says the added backwards compatibility that is now present which was the primary holdup on switching over sooner.
from cdi.
I will give a little bit more detailed information about the use case I have, maybe it's more easy to understand.
We have a project that consists of several sub-projects, possibly all connecting to different environments (so not Prod, Dev, Test, etc.
).
As we wanted simplify the handling we thought about a determined place to put the different configuration.xml files inside the classpath.
We then merge those to a big configuration.xml and let the application inject the according mappers by just using a qualifier with their environment as an argument (e.g. @Environment("ABC")
).
That way it is not needed that an application provides an own producer and the configuration handling would be centralized at a single point.
This would be quite easy by using a @NonBindinding
field inside the qualifier and use the InjectionPoint
as a method parameter of the producer.
The big problem we faced is that mybatis already registers various mapper beans at startup and we can't access the injection point and therefore not use the qualifiers parameter inside the producer that constructs the session factory.
from cdi.
Hi @Juchar , I am sorry. This feature won't be included any time soon. Y Suggest you to create a fork and do some experiments, then if you want you can contribute any enhancement via a PR.
from cdi.
Related Issues (20)
- UnsatisfiedResolutionException: Api type [] is not found with the qualifiers... HOT 7
- Consider support JNDI obtain UserTransaction?
- Weld 3.1.7.Final Proxy changes has broken mybatis-cdi support HOT 1
- Create annotation to rollback exception by default HOT 1
- Upgrade to jakarta Namespace HOT 17
- UnsatisfiedResolutionException using aries-cdi 1.1.5 with karaf 4.3.7 HOT 1
- Dependency Dashboard
- Migrate from atomikos to narayana HOT 1
- Site plugin and 'clirr' usage issue with jakarta
- Clirr: Remove profile from maven.config file after no longer needing to compare to javax namespace
- missing @Any qualifier on MybatisBean if user provided qualifier is present
- Transactional (mybatis-cdi: org.mybatis.cdi.Transactional) annotation with rollbackOnly=true not rollbacking transactions inside a Weld / JUnit 5 test
- issue with micro profile standard HOT 1
- Release 1.0.3 HOT 4
- NoSuchElementException in test with Arquillian and embedded container HOT 10
- "WELD-001328: Unable to identify the correct BeanManager." occurs HOT 16
- Test issues - 8 of 13 can run concurrently / recent updates do not support oldest support revision of cdi/weld HOT 5
- github is behaving very strange... HOT 1
- mybatis-cdi-1.0.3 crashes in repeated requests HOT 2
- Release mybatis-cdi 1.1.0 HOT 2
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 cdi.