Skip to content
Advertisement

Tag: java

Spring data mongodb. Generating id’s error

I have made an experiment… one common entity for two Spring data’s repositories: – JPA – MongoDB first of all I’ using following libraries versions: spring-data-jpa : 1.7.0.RELEASE spring-data-mongodb : 1.6.0.RELEASE I have an Entity: JPA Repository has following look: MongoDB repository has following look: package ua.home.springdata.investigation.repository.mongo; So… JPA works 🙂 Nothing special 🙂 But MongoDB test is not passed

HibernateException: Couldn’t obtain transaction-synchronized Session for current thread

I’m getting the following exception when trying to use my @Service annotated classes: The way I initialize my application is complicated so I need to provide a link to the full base code to get additional information: https://github.com/dtrunk90/webapp-base. I’m using this as a maven overlay. And here is the necessary code: Initializer (from webapp-base): Initializer (from my webapp): @Configuration (from

Handling an exception as a method argument

I am looking for a design pattern to handle Exception instances received as method arguments. To put some context into the question, I am using GWT and have various asynchronous handlers that usually come in a form similar to: So, the onFailure method receives a Throwable instance that I need to handle. Now, I have a number of exceptions I

How do I inject a logger into a field in the sample spring boot application?

What I want is to make spring autowire a logger. So, in other words, I want to have this working: Right now it throws an exception at startup: “No qualifying bean of type [org.slf4j.Logger] found for dependency…”. My pom.xml dependencies: I read this: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-logging It says if you use one of the starter poms (I do) Logback is used –

How to convert String into Hashmap in java

How can I convert a String into a HashMap? into Where the keys are first_name, last_name and gender and the values are naresh, kumar, male. Note: Keys can be any thing like city = hyderabad. I am looking for a generic approach. Answer This is one solution. If you want to make it more generic, you can use the StringUtils

Code in “catch” block not executing

please help me understand why:) My program reach the “try” line, but seems to skip the “catch”, Although its printing the stacktrace… I’m using JOptionPane in my catch, but also System.out.println() not working. Code: Exception: Answer There is an NullPointerException internally just before the FileNotFoundException From your log. You can make sure it from following. This code here only for

How to use (primitive) autoboxing/widening with Hamcrest?

I came across https://code.google.com/p/hamcrest/issues/detail?id=130 to add some sugar syntax for Hamcrest matchers. But the idea was rejected by the Hamcrest developers. Any other smart ideas to make tests better readable by avoiding having to type L behind longs? UPDATE See also below the differences when comparing e.g. int and long using default Java laguage (==), standard junit assert (assertTrue) and

Advertisement