-
Notifications
You must be signed in to change notification settings - Fork 191
No option to exclude class name field from generated queries [DATACOUCH-179] #493
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
Comments
Simon Baslé commented At first, it doesn't seem that hard a feature to request... But ultimately repositories have to be opinionated on the way they interpret data in store in order to provide out of the box marshalling and unmarshalling! Basically repositories are supposed to be a self-contained tool to deal with entities they persisted themselves. The Here your second query by chance only select airport documents, because they are the only ones to have an icao... Travel-sample contains no less that 4 different types of data. If you change the query to use a more generic field, then you're going to have a problem. If you're not prepared to let the application using the Repository in charge of generating and persisting the data (with a possible delta of a data migration), then Repository is probably not the best abstraction for you. What you could use is the |
Abhijit Sarkar commented I think there's an easier way to get what I want and still fit with the existing framework. The classname is nothing but type. Acc. to this blog, there's already a way to rename the field. But the code, I forgot the class name, picks the value as the Java class. Instead, if you extend the |
Mike Shindle commented Instead of extending the |
Abhijit Sarkar commented IMHO, the whole point of Spring Data is to avoid writing boilerplate code. That's why faced with this issue, I just resorted to using Couchbase native Java client. They're reactive compliant, something Spring Data isn't and I can do a lot more using |
Sev Burmaka commented Do you happen to have a link to the PR and affected code? I'm interested in this approach |
Abhijit Sarkar commented
|
Sev Burmaka commented
|
Eduard Dudar commented Agree that there should be an option for exact type value to be provided. Current approach with full class name is not convenient or flexible. It may work fine for hobby-size projects but as soon as you have XX GBs of data in production and you need to move classes around (refactoring... that thing that happens very often in real-world projects) - you're totally screwed. Even if I override getTypeKey() with specific field, secondary indices are still created with a full class name as a value |
Simon Baslé commented
The type information itself isn't going away, as it is there for a reason. The fact that Couchbase can store heterogeneous data in the same bucket is an additional challenge: how should methods like But it could make sense for the query derivation not to select relevant couchbase documents based on the Instead query derivation and methods like Ultimately, support for a configurable string-to-class mapping could also be added (there's one in spring-data-mongo IIRC) |
Eduard Dudar commented Simon, I don't advocate to remove this info completely but just to make it a little more flexible. Document level annotation or even that solution you've mentioned from |
Abhijit Sarkar opened DATACOUCH-179 and commented
Working with the sample bucket
travel-sample
, I created this method in aCouchbaseRepository
:Airport findByIcao(String airportCode);
The corresponding N1QL query that's generated is this:
However, as shown below, the sample bucket documents don't have a
_class
field. Thus the query doesn't find anything.Thus, I'm forced to put a
@Query("$SELECT_ENTITY$ WHERE icao = $1")
on the method that produces the following N1QL, and expected result:There should be an option, probably repository level, and perhaps also query level, to not add the class name to generated queries
Affects: 2.0 M1, 2.0 RC1
Referenced from: commits f453441, 61731ae
2 votes, 7 watchers
The text was updated successfully, but these errors were encountered: