MapStruct
jstachio
Our great sponsors
MapStruct | jstachio | |
---|---|---|
24 | 27 | |
6,797 | 213 | |
1.5% | 16.4% | |
7.8 | 9.3 | |
28 days ago | 4 days ago | |
Java | Java | |
Apache License 2.0 | BSD 3-clause "New" or "Revised" License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
MapStruct
-
Is .NET just miles ahead or am I delusional?
Currently using .NET and ASP.NET for the API of a project that I'm working on, overall it's a pretty lovely experience, especially with the JetBrains Rider as my IDE. Having worked with Java in the enterprise in the past, it feels like a more focused and sometimes more coherent experience (vs the more decentralized nature of Java), that now thankfully runs fine on Linux as well, don't even need to hope that Mono is good enough anymore.
Entity Framework Core is great, the way how they fetch related data is straightforwards: https://learn.microsoft.com/en-us/ef/core/querying/related-d...
I also really like the ability to use split queries, when needed: https://learn.microsoft.com/en-us/ef/core/querying/single-sp...
You can even scaffold your entity mappings from an existing database and manage database migrations separately (which I feel is a must unless you want to pour hours upon hours into learning yet another JPA-like), it's nice when something like that exists in a given ecosystem: https://blog.jetbrains.com/dotnet/2022/01/31/entity-framewor...
Some of the stuff in the ecosystem is also really nice, like using ActionBlocks from Dataflow for simple queues and task scheduling is very easy to get started with and pretty pleasant: https://learn.microsoft.com/en-us/dotnet/api/system.threadin...
Honestly, most of the docs that I've come across are rather pleasant and there's plenty of code examples to be had and even LLMs have enough codebases out there to be trained on and give decent output, in addition to the regular autocomplete in the IDE.
Even some third party stuff like CsvHelper is really well put together: https://joshclose.github.io/CsvHelper/getting-started/#insta...
That said, I've had issues where trying to deserialize incoming JSON requests ([FromBody]) lead to the whole object being null, due to it not matching the fields 1:1 or violating some nullability constraint, however that happened without a clear error message or as much as a warning in the logs, which felt insane and wasn't very discoverable. Now I just use JObject as the parameter and deserialize at the top of the controller method.
I've also run into some ecosystem issues where the OpenAPI codegen was a bit lacking and wouldn't actually generate code that works, but maybe that's because the spec was bad: https://openapi-generator.tech/docs/generators/csharp
I could also not get AutoMapper (https://docs.automapper.org/en/stable/index.html) working satisfactorily, so for now I'm stuck writing mappers by hand with said autocomplete sometimes doing it for me. There were issues with the runtime being unable to register the mappers or something like that, it was a while ago. Overall it felt like the MapStruct library in Java did everything better: https://mapstruct.org/
On the other hand, I haven't had any of the Spring Boot DI related headaches (needing @Lazy sometimes) with ASP.NET, things there seem way more straightforwards and you clearly define whether something should be a Singleton or Scoped and the rest... just gets out of your way and works.
Sadly, there have been very hard to track down cases where I try to do a _dbContext.Add(someEntity) and then when I do a save with just the fields in that one entity changed, the performance absolutely seems to slow down to a crawl. Adding _dbContext.ChangeTracker.AutoDetectChangesEnabled = false seemed to help, but I am still not entirely sure what lead to that behavior, the temp directory on my Linux box also started filling up very rapidly, yet the logs had nothing of use, definitely seems like something I'd need to investigate properly.
Overall, .NET and its ecosystem is pretty good in most cases. And .NET being used in gamedev is also cool, for those who care about that sort of thing, I wonder why jMonkeyEngine never really took off.
-
Object mapping libraries
In Java (woof..) we have MapStruct (https://mapstruct.org/). Anything like that in Python? I think maybe the Sqlalchemy mapping in Litestar2 is the closest I've seen.
-
Feedback on a new annotation processor api
Done right i can look something like mapstruct for example. But like any other feature you need to get a feeling for when it's a good idea to use it.
-
Mapping in Domain Driven Design sucks
We are using mapstruct but it sucks when you have protobuf :/
-
must known frameworks/libs/tech, every senior java developer must know(?)
You all beat me to MapStruct and Testcontainers. Honorable mention to RxJava, which I use in Desktop apps.
-
Correct way of exception handling, an optional?
For the mapping, I'm using Mapstruct, I got the instance example from their examples they use INSTANCE as constant.
- Ask HN: What are your “scratch own itch” projects?
-
What next Springboot?
Now update your code so that no entities are passed to/from the domain layer and that no objects are passed to/from the domain layer. You'll look at me as though I'm nuts, but you will thank me later. Look at things like http://immutables.github.io/ and https://mapstruct.org/
-
Using MapStruct and Lombok with Inheritance
When my pairing partner and I ran into this use case, we were initially stumped. Even our combined Google Fu efforts were not turning up a good solution. However, we eventually discovered a PR for MapStruct that seemed to be the solution to our issues! But, of course, if it were that simple, I would not be writing this now. The SubClassMapping annotation provided by that PR, while quite helpful, requires specific Mapping annotations for every field on the subclass. We wanted a more elegant solution.
-
We released a new version of ShapeShift (0.6.0) - A lightweight, modular, performant and extensible object mapping library
Just use MapStruct...
jstachio
-
Full stack web development in a single Java file: An intro to Javalin and htmx
Anyway it was one of the reasons we (my company) went with Mustache and why I wrote JStachio.
-
HTML template languages?
I don't know Dart that well (only experimented with simple apps) and just kind of lurk on this sub but I am the author of a HTML templating language (Mustache) in Java that uses annotations and code generation: https://github.com/jstachio/jstachio
- Show HN: JStachio a type-safe Mustache engine that is incredible fast
-
Feedback on a new annotation processor api
Things like this https://github.com/jstachio/jstachio (author) would not be possibly with just an include like preprocessor.
- Interpolating Strings Like a King in Java 21
-
Hey guys, just wanted to let you know that JStachio v0.9.0 is now out and it even comes with Spring support! So go ahead and give it a try if you're into that kind of thing!
Hey guys, wanted to share my project JStachio with you all. It's a java templating engine that's like Mustache.java and Handlebars.java in syntax but also compile time type safe like JTE, Rocker, and Qute.
-
Introducing Bld: A New Pure Java Build System
On a related note I have been really liking the newer Java feature of being able to execute .java files directly. I have been using them frequently to execute what would normally be a Bash or Python script. I actually have a Java .java script that mimics some parts of the Maven release plugin and because Java speaks XML really well it was easier to implement it in Java than Bash or some other scripting language which makes me think /u/bowbahdoe point on including a JSON parser with the standard lib would be very useful.
-
Modern frontends using Spring Boot and Thymeleaf (yes, modern, you read it right, as in SPA)
I plan on releasing an unpoly (htmx like library) petclinic using my templating library https://github.com/jstachio/jstachio (superior to thymeleaf but I’m biased) and some avaje + Jooby. Hopefully next month.
-
What's the point of autogenerating DTOs from entities?
But going back to they can generate whatever they want they could even make an expression or template language that is type safe (and I know this is possible as an author of such a library).
-
JEP 430: String Templates (Preview) Proposed to Target Java 21
For those that do not like the syntax and still want compile time string interpolation check out my library: https://github.com/jstachio/jstachio
What are some alternatives?
ModelMapper - Intelligent object mapping
jte - Secure and speedy templates for Java and Kotlin.
JMapper Framework - Elegance, high performance and robustness all in one java bean mapper
quarkus-qute
Orika - Simpler, better and faster Java bean mapping framework
savant-core - This is the main project for the Savant build tool
Dozer - Dozer is a Java Bean to Java Bean mapper that recursively copies data from one object to another.
jamal - Jamal is document maintenance automation
Selma - Selma Java bean mapping that compiles
stringtemplate4 - StringTemplate 4
record-builder - Record builder generator for Java records
Mustache.java - Implementation of mustache.js for Java