-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Identifiers trait #16
Comments
Hi,
There is a general problem with the sample usage of Unicorn shown in the README:
In order to use I think the simplest solution is to remove |
@javajumbo Resolving this issue could be problematic in terms of unicorn We introduce parameter to Unicorn for Underlying type. It's easy to resolve definition of data in this use case.
using this would be same as using in core examples.
|
Hi - I am not sure if I follow your comment fully, but I've looked at the commits linked to this issue, and they look pretty much along the lines I was expecting, so should solve my issue. I will give it a try by replacing my custom hack with 0.6 version. |
do you guys have a working example of configuring UnicornCore without static driver selection? I used to be able to define my model classes without any cake pattern, simply as
Not it seems even for a simple data model I have to import from an object extending unicorn. In such object I assume I cannot just leave the driver member as ???, can I? It seems in 0.6.x the cake pattern was extended way more than needed. |
We want to make usage of unicorn as simple as possible. The main reason that cake pattern is used in project is that slick use it heavily. The core example shows how to use unicorn without using cake in project. Right after you define your bake cake
the usage in code is simply as you describe
If this solution is temporally, ex. database will be chosen later but still in project) yes, but you will be unable to perform any runtime test (exception on loading class will be thrown. I was tested this scenario on previous response). Moreover you could make your implementation like this
Implementation like this is used in So, for development (differed choose of static driver) you could use
I didn't see other way how to implement parametrization for arbitrary |
Hm, I think we're back to my original problem. Even with the parametrization, the data model should not need anything more than static imports
Then when defining the Unicorn class, I wouldn't expect to provide a parameter at the top level, because the business function of the Unicorn class is to wire in the driver implementation. Which ID type to use on the tables is already known when we use the types defined above in the IdTable:
Here we know that the ID type is String. The problem I have with the Play pattern is it forces the driver selection too early. Yes, you can delay it by reading it from the config, but it means I need to have a config even to run the unit tests. With 0.5.x (after I hacked it to remove the Identities trait) I simply had a trait SlickTestSupport I needed to mix into the unit test classes, where the DAL object was initialized with the underlying Unicorn object.
Then in the real application, I would instantiate MyDAL with a driver loaded based on the configuration and let Spring inject it where needed. As a result, I have data model independent of the driver, all knowledge of Unicorn and Slick is encapsulated inside the MyDAL class. |
Remove unneeded trait
Identifiers
. All class from him is not depend on cake classes, so they could be top level.The text was updated successfully, but these errors were encountered: