3 ms·
Code like this is expected in Spring https://hastebin.com/jevibugiqu.less https://hastebin.com/jevibugiqu.less . Literally all the classes I see are filled with
by mesarvagya 4y ago
Code like this is expected in Spring https://hastebin.com/jevibugiqu.less https://hastebin.com/jevibugiqu.less . Literally all the classes I see are filled with annotations. Can we even write code in pure java without a single annotation ? Theres a lot of magic going on with annotation. It works great while it is running. God forbid there is some issue and we have to figure it out where all the magic is happening.
- KronisLV 4y agoThat is actually a JPA mapping for your persistence layer, which is one of the relatively few things where lots of annotations should be acceptable (except for the inevitable runtime problems due to foreign data mappings): https://en.wikipedia.org/wiki/Jakarta_Persistence https://en.wikipedia.org/wiki/Jakarta_Persistence It's not even that bad, when you consider something like myBatis, which can be useful for cases where you need complex dynamic SQL for your models, but can also involve boilerplate if you don't have codegen: https://mybatis.org/mybatis-3/sqlmap-xml.html https://mybatis.org/mybatis-3/sqlmap-xml.html Though in regards to service code and such, I agree, it can get out of hand and be a total mess sooner rather than later. Not being able to properly debug this magic is just the cherry on the top.
- cutler 4y agoIt was the @Query annotation which finally killed Spring for me. So I have to stuff all my SQL into an annotation now if I want raw JDBC? Madness. **ck that.
- kaba0 4y agoWhy would you have to do that? You can just inject an entitymanager to wherever you want to use it natively and do whatever you want.
- cutler 4y ago"inject an entitymanager"?? I don't even have any entities, just a db I want to query with raw sql.
- nick__m 4y agoNothing in Spring-boot force Hibernate upon you. I stated that I used to use mybatis, a resultset mapper... it's a lot closer to JDBC and if you really need raw JDBC, have a datasource injected where it's needed.