Some Trials & a lot of Errors

I tried a bunch of framework and other language and I usually feel overwhelm when its time to do something real with what I've learned. So that why I created this site, to write my progress and help some noob like me that stumble into the sames problems.

Browse: Page 7

How to get 70 Millions with only a 5$ investement!

By Chris on June 22, 2021

There is a 70 M lottery draw this week plus 70 one million prizes, I know this is no powerball, but here in Canada we are pretty excited. Even my wife is like: “We need to buy a ticket”. And she bought one with her father because 35M is still an insane amount of money. Well when the draw was 50M or “just” 30M it was still an insane amount of money, enough to change your life (sometime for the worst).

I usually don’t buy lottery tickets, but when I do, it’s for the fuzzy feeling of what I will do if I win the jackpot. I would probably try to figure out what I need from it to generate a decent income each year to live a good life. From there, the rest would be to give away to family, friends and charity and maybe some upgrade (my beat up toyota definitely needs an upgrade). What weird we almost always imagine ourselves what it would be like to win the jackpot but never think about the secondary prize. Winning a million is nice too, but not life changing like 70M.

I’ve met people who seem to consider lotteries like an investment. I even heard some crazy story of actually robbing a bank to buy lottery tickets and use the winning to pay back the loan (True story, there’s bank manager lending himself some money to buy a lot of ticket).

While putting money in the stock market may seem like playing in a casino, you are still buying an asset (except if you bought Theranos) and while it may go down in value, its value is likely to be higher than your lottery ticket the day after the draw. 

Now back to work! I wish you all good luck and if you win don’t forget to give some back to your communities.

Note: There is no tax on lotteries here in Canada, because let’s be honest, lotteries are already a tax on the poor. 

Posted in rant | Tagged lottery | Leave a response

How to remove array element in mongodb in java?

By Chris on June 17, 2021

In the previous post, we discuss own we change from using mongorepository to using directly mongodb method to access and modify directly the object in db.
In this posts we look at code that was deleting with mongorepository and change it to use directly mongodb method with MongoTemplate.

Using MongoTemplate is faster and less likely to have error due to concurrency.

Here a example of the code original code with mongorepository:

@Autowired
private MongoContentRepository mongoContentRepository;
			
private void removeStudentFromSchool(final Student student) {
   Optional<School> optionalSchool = mongoContentRepository.findById(student.getSchoolId());
		if (optionalSchool.isPresent()) {
            School school = optionalSchool.get();
            List<Student> students = school.getStudents();
            if (students != null && !students.isEmpty()) {
                Optional<Student> optionalStudent = getStudentInSchool(students, student);
                optionalStudent.ifPresent(studentInDb -> students.remove(studentInDb));
				school.setStudents(students);
				mongoContentRepository.save(school);
			} 
		}
    }

To do the same thing by calling the mongodb operator pull with MongoTemplate
Source: https://docs.mongodb.com/manual/reference/operator/update/pull/

Doing a pull directly in a mongodb query work like this:

db.getCollection('contentDetails').update(
    {_id : "1000102088"},
    {$pull: { "students": {_id : "1000102183", name: "John Smith"}}},
    {multi: true}
)

In Java it’s translate to this:

public void removeStudentInSchool(String schoolId, Student student) {
	mongoTemplate.updateFirst(
			Query.query(Criteria.where(CRITERIA_ID).is(schoolId)),
			new Update().pull("student", Query.query(Criteria.where(CRITERIA_ID).is(student.getId()))), COLLECTION_NAME);
}

So if we change the original code to use Mongo template it look like this:

public void removeStudentInSchool(String schoolId, Student student) {
	mongoTemplate.updateFirst(
			Query.query(Criteria.where(CRITERIA_ID).is(schoolId)),
			new Update().pull("student", Query.query(Criteria.where(CRITERIA_ID).is(student.getId()))), COLLECTION_NAME);
}

private void removeStudentToSchool(final Student student) {
	Optional<School> optionalSchool = mongoContentRepository.findById(student.getSchoolId());
	if (optionalSchool.isPresent()) {
		School school = optionalSchool.get();
		List<Student> students = school.getStudents();
		if (students != null && !students.isEmpty()) {
			Optional<Student> optionalStudent = getStudentInSchool(students, student);
			optionalStudent.ifPresentOrElse(studentInDb -> contentCollection.removeStudentInSchool(studentInDb.getId(), details), 
											() -> log.debug("{} already remove from school {}",student.getName(), school.getName()));
	}
}

Like updating in mongodb removing with the $pull operator is atomic, so it solved the concurency problem.

More on the same subject :

https://stackoverflow.com/questions/16959099/how-to-remove-array-element-in-mongodb
https://docs.mongodb.com/manual/reference/operator/update/pull/
https://stackoverflow.com/questions/40292201/mongodb-pull-using-java-driver

Posted in java, mongodb, prog, tips | Tagged java, mongodb, MongoRepository, MongoTemplate | Leave a response

How to update an entry in an array in mongodb with java MongoTemplate?

By Chris on June 10, 2021

We had at work a piece of code that was using mongorepository and updating the arrays of the object on a collection instead of using mongodb method directly.
The way it was coded had a big issues with concurrency and we were losing update because of it.
The problem we had with the way it was updating the array and saving using mongorepository and we are going to fix it using directly mongo queries with MongoTemplate.

Example of code with mongorepository

@Autowired
private MongoContentRepository mongoContentRepository;
			
private void addStudentToSchool(final Student student) {
        Optional<School> optionalSchool = mongoContentRepository.findById(student.getSchoolId());
	if (optionalSchool.isPresent()) {
		School school = optionalSchool.get();
		List<Student> students = school.getStudents();
		if (students != null && !students.isEmpty()) {
			Optional<Student> optionalStudent = getStudentInSchool(students, student);
			optionalStudent.ifPresentOrElse(studentInDb -> {
				if (hasStudentChanged(studentInDb, student)) {
					students.remove(studentInDb);
					students.add(student);
				} 
			}, () -> students.add(student));
			school.setStudents(students);
		} else {
			school.setStudents(List.of(students));
		}
		
		mongoContentRepository.save(school);
	}
		
}

There are a lot of things wrong here.
It saving the whole object each time, which means if there a student is save in mongodb while another one is being save in a longer transaction, it will override the first update.

Using MongoTemplate

You can prevent that problem, by using directly mongo queries with MongoTemplate
Reference: https://docs.mongodb.com/manual/reference/operator/update/positional/

db.getCollection('content').update(
	{_id : "1000102088"},
	{$set : {"student.0.name" : "Joe Smith"}}
)

Or even better (in case the operation might change the order of the element in the array):

db.getCollection('content').update(
	{_id : "1000102088", student: {$elemMatch: {_id : "1000102177"}}},
	{$set : {"student.$.name" : "Joe Smith"}}
)

What does that look like in Java :
If we take the first query and convert to the equivalent code with MongoTemplate:

public void addStudentInSchool(String objectId, Student student, int index) {
	mongoTemplate.updateFirst(
		Query.query(Criteria.where("_id").is(objectId)),
		new Update().set("student.$[" + index + "]", student), COLLECTION_NAME);
}

For the second query we get:

public void updateStudentInSchool(String schoolId, Student student) {
mongoTemplate.updateFirst(
	Query.query(Criteria.where("_id")
		.is(objectId)
		.andOperator(Criteria.where("student")
		.elemMatch(Criteria.where("_id").is(student.getId())))),
		new Update().set("student.$", student), COLLECTION_NAME);
	}

Note: WP code block seems to mess up the indentation.

End result

If we take our initial code and use our mongo template code we get the following end result.

Let’s update addStudentToSchool with MongoTemplate instead of mongoContentRepository:

private static final String COLLECTION_NAME = "schoolCollection";
private final MongoTemplate mongoTemplate;

public void addStudentInSchool(String schoolId, Student student) {
	mongoTemplate.updateFirst(
			Query.query(Criteria.where("_id").is(schoolId)),
			new Update().addToSet("student", student), COLLECTION_NAME);
}

public void updateStudentInSchool(String schoolId, Student student) {
	mongoTemplate.updateFirst(
			Query.query(Criteria.where("_id").is(schoolId).andOperator(Criteria.where("student").elemMatch(Criteria.where("_id").is(student.getId())))),
			new Update().set("student.$", student), COLLECTION_NAME);
}

private void addStudentToSchool(final Student student) {
	Optional<School> optionalSchool = mongoContentRepository.findById(student.getSchoolId());
	if (optionalSchool.isPresent()) {
		School school = optionalSchool.get();
		List<Student> students = school.getStudents();
		if (students != null && !students.isEmpty()) {
			Optional<Student> optionalStudent = getStudentInSchool(students, student);
			optionalStudent.ifPresentOrElse(
        studentInDb -> contentCollection.updateStudentInSchool(school.getId(), student),
	() ->  contentCollection.addStudentInSchool(school.getId(), student));
	} else {
		contentCollection.addStudentInSchool(school.getId(), student);
	}
}

This worked fine for us and we stop having our mongdb update disappearing due to concurrency.

Why did it solve the concurrency issue ?

All $inc $set $unset $push $pushAll $addToSet $pop $pull $pullAll $rename $bit operations are atomic.
This mean if multiple $set or $addToSet are done in concurrency all the operations and lock that entry.

For more information on mongodb concurrency:
https://stackoverflow.com/questions/6997835/how-does-mongodb-deal-with-concurrent-updates
https://docs.mongodb.com/manual/faq/concurrency/

Hope It helped you and have a nice day.

Posted in java, mongodb, prog, tips | Tagged java, mongodb, MongoRepository, MongoTemplate | 1 Response

Books I’ve read in 2020

By Chris on May 30, 2021

At the beginning of 2020, I wanted to read more than my abysmal 2019 three books total. I’ve already read my 2019 total before the whole 2020 ‘situation’ hit. This made it harder for me to read since I was stuck at home most of 2020 and I usually read in my commute. Nonetheless, I managed to read 12 books last year. Here is the rundown of all the books I’ve read last year, I think I might do a full reviews of some of the non-fiction books later this year, we’ll see.

Stillness is the Key

This is the third installment of Ryan Holiday books on stoicism, the two others being Obstacle is the way and Ego is the enemy.

Sometimes when everything seems to get faster, more stressful and even crazy around us. While some philosophy might say to go with the flow, stoics show us that deliberately slowing down is what you should do. By slowing down, you will notice what usually goes unnoticed and, in a Matrix like slow motion montage, dodge what is unimportant and focus on what truly matter.

If you’re into stoicism or like the obstacle is the way or ego is the enemy, then is book is definitely for you. If not I would recommend reading the Obstacle is the way first, I found that some idea are repeated and Obstacle made more of an impact on me. Note that I say this and I’ve read Ego is the enemy first.

Piège au royaume des ombres

Piège au royaume des ombres is the third installment of the French Fantasy Fiction ‘’Les Chevaliers d’Émeraude’’ series. Kira has finally reached an age where she can show what she is capable of and set on an expedition with Wellan, her master and other fellow knights and squire. 

I tend not to review too much fiction because the fun of it is to discover the story and reviewing quickly enters spoiler territory whereas non-fiction having a review will help you decide if the book talks about subject matter you want to expand on or not. 

Everything is F*cked

From the author of  The Subtle Art of Not Giving A F*ck comes a counter-intuitive guide to the problems of hope.

I really liked The Subtle Art of NotGiving A F*ck with his gritty writing and mind opening view so I was really excited when I’ve heard that Mark Manson was writing another book. While I liked the book, I would recommend reading first book before this one, they’re not mutually exclusive and can be read on their own. However, is first book is more packed with information and reflection than this one.

The Power of Creativity

A small book I bought a while ago seems to be part of a series by the same author. It gives some good advice even if it’s mostly stuff I already knew. Advice that is always good to revisit like what your audience demands vs your craft and that you should invest in your side project.

If you follow Seth Godin or read Steven Presfield non fiction you will know most of what he talks about in the book.

Dividend Investing for Everyone

It’s been awhile since I haven’t read a book about investing and I was looking for a way to invest that could create recurring revenue from investing. This book is short and sweet if you already know a bit about investing in general. However, the lack of a table of index is a bit annoying for this review though. He goes on explaining what is dividend investing and how it will generate more money for you that bond and saving account. The most interesting part of the book is when he shows how he picks his own dividend stock, what are his criteria and what type of dividend stock there is.

The Lost Symbol (Fiction)

Note I’ve read this one in french, Le symbole perdu by Dan Brown.

The sequel to the famous Da Vinci Code, we follow again professor Robert Langdon, this time involved in a plot linking the Freemason and the founding father.

I won’t spoil you much, if you liked Da Vinci Code you will like this one. I follow the same formula of his last book, a little too much in my taste. I had the impression that in some part of the book I was just rereading Da Vinci code, but except for being in Paris we’re in Washington.

Conspiracy

Another book from Ryan Holiday, this time not really the kind of book we are you to get from him. Holiday dissects the involvement of Billionaire Peter Tiel in helping bring down publisher Gawker by helping Hulk Hogan in his trial against them without Hogan knowing it. 

Tiny MBA

When I saw one of stackingthebricks author wrote a book I immediately ordered it. Unfortunately it didn’t live up to the level of their amazing long form post they usually do. It’s more like someone was following every business thought leader and CEO and collected all theirs insightful tweets then put them in a book. While some can really be inspiring and insightful, you kind of eager to want more after going through it.

Stop People Pleasing

Stop people pleasing is about how to balance helping other people and not being a yes man that other people don’t value your time. I think I got this one through a newsletter that sells books for one dollar and sometimes gives freebies.

The main takeaway of the book: is to learn what you want to say yes to and no to, common phrases to use to imply a no without saying it and stay away from manipulators.

Live of the Stoics

A third book from Ryan Holiday this year, this one is more in the vein of the Daily stoic I’ve read through in 2018 (http://cjacques.me/the-20-books-ive-read-in-2017/). He goes through the list of all the major stoics from the founder of stoicism Zeno to philosopher king (emperor) Marcus Aurelius. I’m kind of a sucker for this book because it’s a mix of things I like to read about, Roman history and philosophy. If you’re interested in one or both of these subjects it’s definitely a good read.

The Art of Learning

Josh Waitzkin, former chess prodigy and martial Tai Chi World champion, walk us thought is life and how he learned to master those two disciplines in this self-help memoir.
While Waitzkin can kinda sometime sound like a d*&k and that can be off putting at time, he goes deep into what was going in his mind in different key learning points in his life. While being world class might not be your thing, understanding what got them to that point can definitely be useful.

Learn Like a Polymath

I got this one on a kindle sale. It might be a good idea to do the same. There are some tips and tactics that I’ve probably read in other books like space your learning, deconstruct what you learn to a manageable piece. However, instead of focusing these on the broader concept of learning the author apply them at connecting knowledge between disciplines.

If you’re interested in learning in general or searching for a way to connect knowledge between your field of interest you will probably find some good nuggets here and there.

Posted in book | Tagged 2020, book, books, List, reviews | Leave a response

Assert an Exception is Thrown in JUnit 4 and 5

By Chris on May 19, 2021

This is old news, but having work with big bank and insurance companies they tend to stick with the old version of java and they’re underlying libraries, I’ve finally been expose to new ways of testing exception with junit.

I use to test exception by adding an expected right after the @Test annotation.
@Test(expected = NullpointerException)

However they’re many other ways to do that with only junit5 and mockito

Option 1: Stinking with junit4 you can define an expected exception:

@Rule
public ExpectedException bob = ExpectedException.none();

@Test
public void testShareContentFileConflict() {

    bob.expect(ConflictException.class);
    bob.expect(hasProperty("accountId", is(MASTER_ACCOUNT_ID)));

    Mockito.when(service.getSharedId(MASTER_ID, MASTER_ACCOUNT_ID, AFFILIATE_ACCOUNT_ID)).thenReturn(null);
    Mockito.when(service.shareContent(MASTER_ID, MASTER_ACCOUNT_ID, AFFILIATE_ACCOUNT_ID)).thenThrow(new ConflictException(MASTER_ACCOUNT_ID, "Error occurred"));

    // call manager
    String returnedAffiliateContentId = contentManager.shareContent(MASTER_ID, MASTER_ACCOUNT_ID, AFFILIATE_ACCOUNT_ID);

    // validations
    Assert.assertEquals(AFFILIATE_CONTENT_ID, returnedAffiliateContentId);
    Mockito.verify(service).shareContent(MASTER_ID, MASTER_ACCOUNT_ID, AFFILIATE_ACCOUNT_ID);
}

Option 2: JUnit5 introduces the assertThrows method for asserting exceptions.
This takes the type of the expected exception and an executable functional interface where we can pass the code under test through a lambda expression.

@Test
public void whenExceptionIsThrown_thenAssertionSucceeds() {
    Exception exception = assertThrows(NumberFormatException.class, () -> {
        Integer.parseInt("1a");
    });

    String expectedMessage = "For input string";
    String actualMessage = exception.getMessage();

    assertTrue(actualMessage.contains(expectedMessage));
}

Option 3: Using mockito & assertJ:
If you’re using mokito and assertJ in your test already, there an another clean way to do it. It’s so far my favorite.

given(xxx).willThrow(new MyException())
when {() -> myService.doSomething()}
then(caughtException()).isInstanceOf(MyException.class)

They are other way to do it just with mockito using doThrow, thenThrow and spy which are explained here.

Posted in java | Tagged assertJ, java, junit, junit4, junit5, mokito, testing | Leave a response

Solving LazyInitializationException with sonar rules @Transactional method called from another method doesn’t obtain a transaction

By Chris on May 12, 2021

We recently added a feature that allowed direct modification on our content for some client vs using the same path (queues) that the batched content is using.
Our user were really happy with it, but after our team implemented the new feature, we started having some LazyInitializationException.

exception for that problem

org.hibernate.LazyInitializationException: could not initialize proxy [com.company.dbservice.model.Image#1004291143] - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:170)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:310)
at org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor.intercept(ByteBuddyInterceptor.java:45)
at org.hibernate.proxy.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:95)
at com.company.dbservice.model.Image$HibernateProxy$aWvtUHZY.getContent(Unknown Source)
at com.company.dbservice.search.resolver.ImageResolver.getImageUrl(ImageResolver.java:50)
at com.company.dbservice.search.resolver.ImageResolver.getContentImageUrl(ImageResolver.java:34)
…..
at com.company.dbservice.aop.ReadOnlyRouteInterceptor.proceed(ReadOnlyRouteInterceptor.java)
at com.company.dbservice.sqs.reader.MessageHandler.processMessage(MessageHandler.java)
at com.company.dbservice.sqs.reader.MessageHandler.receiveMessage(MessageHandler.java)

After looking at, it those errors seem to keep happening to object in object in object that were not needed anyway so the unnecessary acces were remove to prevent processing these object. It a solution you might say but this don’t solve the underlying issue.
Here an example of the table surrounding the object.

table-image-countries

When I look in new relic the next they I notice that the error were still happening.
This time it was for an object that was needed. After some digging, I found out that the new endpoint for the direct route didn’t have the @Transaction annotation. It was calling the same code to save and process the object the batch part was using though.
For those who don’t know @Transactional tells spring to create a proxy around the object. The proxy intercepts calls to the object from other objects. The proxy does not intercept calls within the object.

So to fixed we had to add @Transactional on the method that is invoked from “outside” and it fixed the problem.

Related: Hibernate could not initialize proxy – no Session

Posted in java | Tagged Exception, hibernate, java, LazyInitializationException | Leave a response

Why does Map.of not allow null keys and values?

By Chris on March 2, 2021

Once upon a time an engineer with years of experience encounter something so basic he doesn’t understand why he didn’t encounter it sooner.

Note the java map you’re looking for.

This week we had a strange error in our log stating that should have a null values in a map.

After some digging in the service where that log was found, it seems to be not coming from us…

But why can’t a map have a null values. It’s easy to understand why we can have a null key value but why can’t the value be null?

Well it make sense, why keep an empty record in a key when you could just remove the key and it’s not in the map it means it’s null. That free up the map to make it more efficient.

If you straight up initialize a map with Map.of() and include a null value, it will throw a null pointer exception. However, if you do it with a HashMap it will work fine. You can even have null key that way. Most modern implementation of map won’t allow null in their keys or values.

If you want a better explaination checkout this stackoverflow answer: Why does Map.of not allow null keys and values?

Here the TL;DR:

Allowing null in collections is by now seen as a design error. This has a variety of reasons. A good one is usability, where the most prominent trouble maker is Map::get. If it returns null, it is unclear whether the key is missing or the value was null. Generally speaking, collections that are guaranteed null free are easier to use. Implementation-wise, they also require less special casing, making the code easier to maintain and more performant.

Null elements, keys, and values will be disallowed. (No recently introduced collections have supported nulls.) In addition, prohibiting nulls offers opportunities for a more compact internal representation, faster access, and fewer special cases.

Since HashMap was already out in the wild when this was slowly discovered, it was too late to change it without breaking existing code but most recent implementations of those interfaces (e.g. ConcurrentHashMap) do not allow null anymore and the new collections for the factory methods are no exception.

So disallowing null had some technical reason but it was also done to improve the robustness of the code using the created collections.

Posted in java | Tagged java, java.util.Map, maps, null | Leave a response

Book I’ve read in 2019…

By Chris on February 10, 2021

I know 2019 is like light years away, but I haven’t had the time to write and you will see that I haven’t had much time to read either in 2019. Having a baby who doesn’t sleep will do that to you.

How to be miserable

I got this book after watching CGP Grey’s “7 Ways to Maximize Misery“. I recommend both the video and the book – the video is based on seven of the 40 strategies given in the book.

Excellent reverse psychology to avoid doing the list of actions that will make you miserable. Some of the excerpts had me in tears laughing because I could see what I had been doing without really realizing it. After starting that list I’ve read some part of the book again, I definitely will put that book in my re-read list.

The gift of failure: How the Best Parents Learn to Let Go So Their Children Can Succeed

In our overprotective society, Jessica Lahey warns us that shielding our kids too much from mistakes is not actually helping. We need to let them make their own mistakes in order to learn and be ready later in life. Failure should not be looked at as a negative, but rather a stepping stone to success.

A great book that state the obvious, today kids are so shielded from everything they don’t get to experience what it’s like to live and this might have some dire consequences when they get older and need to leave the nest. It’s helped me worry less about grades (a little less) and everything around them and let them be kids, let them experience the world with their genuine curiosity and thirst for knowledge.

The storm before the storm

From the triumph to the fall of the Roman republic this book goes into the bloody details of what happened during that time.

I was a big fan of Mike Duncan podcast on Roman history and I love how he tells the stories of these Roman citizens. This book is no different, I couldn’t put the book down near the end even though I knew where this was heading and the implication of what would come next.

If you’re a fan of Roman history I highly recommend it. If you want to understand the parallel between that period in history and our current US event you can checkout his interview on Ryan Holiday Daily Stoic podcast.

Posted in book | Tagged 2019, book, How to be miserable, The gift of failure, The storm before the storm | Leave a response

Constructor XXX in enum XXX cannot be applied to given types in mapstruct

By Chris on May 20, 2020

I was having that weird error when I was working with mapstruct, turn out that the default java version for mapstruct is java 6. Since our project was in java 11 I was getting the error “Constructor XXX in enum XXX cannot be applied to given types”.

My starting config was :

        <dependencies>
             <dependency>
                 <groupId>org.mapstruct</groupId>
                 <artifactId>mapstruct</artifactId>
                 <version>${org.mapstruct.version}</version>
             </dependency>
         </dependencies>
         <build>
             <plugins>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-compiler-plugin</artifactId>
                     <version>3.8.0</version>
                     <configuration>
                         <release>${java.version}</release>
                         <source>1.6</source> <!-- or higher, depending on your project -->
                         <target>1.6</target> <!-- or higher, depending on your project -->
                         <annotationProcessorPaths>
                             <path>
                                 <groupId>org.mapstruct</groupId>
                                 <artifactId>mapstruct-processor</artifactId>
                                 <version>${org.mapstruct.version}</version>
                             </path>
                         </annotationProcessorPaths>
                     </configuration>
                 </plugin>
             </plugins>
         </build>

After some research, turn out there a mapstruct version for java 8 and more. You can use the following maven to configure mapstruct for java 8 or higher :

        <dependencies>
             <dependency>
                 <groupId>org.mapstruct</groupId>
                 <!-- use mapstruct-jdk8 for Java 8 or higher --> 
                 <artifactId>mapstruct-jdk8</artifactId> 
                 <version>${org.mapstruct.version}</version>
             </dependency>
         </dependencies>
        <build>
             <plugins>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-compiler-plugin</artifactId>
                     <version>3.8.0</version>
                     <configuration>
                         <release>${java.version}</release>
                          <!-- or higher, depending on your project -->
                         <source>1.11</source> 
                         <target>1.11</target> 
                         <annotationProcessorPaths>
                             <path>
                              <groupId>org.mapstruct</groupId>
                              <artifactId>mapstruct-processor</artifactId>
                              <version>${org.mapstruct.version}</version>
                             </path>
                         </annotationProcessorPaths>
                     </configuration>
                 </plugin>
             </plugins>
         </build>

Let me know if you had that problem and if this helped you.

Posted in error, java | Tagged java, java8, mapstruts, maven | Leave a response

Book Review Autumn 2018

By Chris on January 8, 2019

Perenial Seller:
The Art of Making and Marketing Work that Lasts 

I’m subscribed to Ryan Holiday newsletter and read is latest work on stoic philosophy (Obstacle if the way, Ego is the Enemy, Daily stoic) and when he usually get a book out I buy it.
In his book, Perenial Seller, we study on what it takes to create timeless, lasting work. Ignore the trends of the day to focus on what matters and what will lead to real impact.
If you want to write, produce, or build something amazing, read this book.

Principle by Ray Dalio

A big book (600+ page) about one of the great Investor of our time, Ray dalio and is life and work principle.

Ray Dalio is the founder and co-chairman of Bridgewater Associates, which, over the last forty years, has become the largest and best performing hedge fund in the world.
Mr. Dalio let us dive in in this part memoir, part how-to guide and show us what priciple guide is life and business.
My main take away of this book is to pratice radical honesty, which is the ability to open oneself to appreciate pointed criticism and use it to improve and have a sense of humility and introspection.
There 3 main part in the book, is biography to understand where he come from, is life principle and is work principle that he used to build Bridgewater.

Factfulness

I bought this book after seeing Bill Gates recommendation, and my god this book is eye opening. Hans Rosling explains how what we see on the media, our preconceptions and statistical illiteracy make us believe in the wrong worldview. Surprise, surprise, other countries aren’t like they used to be 50 years ago. The book carefully break the 10 most important sources of bias and misconceptions and give ways to avoid them. Forget about the “Developping world”, most countries today would be considered developed. We should categorize the developments in four income level instead and at the end of the book there are examples on what different in the life of a level one vs other level of income. Each countries have average income level that help us determine the problem of the population and the degree of extremes poverty.

Posted in book | Tagged 2018, book | Leave a response

« PreviousNext »

Tags

2018 2022 app apparment baby book books cleaner date daycare db fantasy draft fantasy sports food foods fridge games gifts grocery hibernate hockey hockey pools ideas inspiration java java.util.List learning List meal plan meal planner motivation mysql oracle productivity retail shopping reviews service social games sql String students The Practice to_date uber wedding

Recent Comments

  • pawan on How to update an entry in an array in mongodb with java MongoTemplate?
  • kevin on Oracle have no Boolean, how to fix this

Calendar

January 2026
MonTueWedThuFriSatSun
 1234
567891011
12131415161718
19202122232425
262728293031 
« Dec  

Archives

  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • March 2021
  • February 2021
  • May 2020
  • January 2019

Copyright © 2026 Some Trials & a lot of Errors.

Powered by WordPress and Hybrid.