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
Tag: java
Detect doubleclick on row of TableView JavaFX
I need to detect double clicks on a row of a TableView. How can I listen for double clicks on any part of the row and get all data of this row to print it to the console? Answer Here is a complete working example:
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
Java and GUI – Where do ActionListeners belong according to MVC pattern?
I’m currently writing a template Java application and somehow, I’m not sure about where the ActionListeners belong if I wanted to cleanly follow the MVC pattern. The example is Swing based, but it’s not about the framework but rather the basic concept of MVC in Java, using any framework to create GUI. I started with an absolutely simple application containing
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
Android 5.0 – Add header/footer to a RecyclerView
I spent a moment trying to figure out a way to add a header to a RecyclerView, unsuccessfully. This is what I got so far: The LayoutManager seems to be the object handling the disposition of the RecyclerView items. As I couldn’t find any addHeaderView(View view) method, I decided to go with the LayoutManager’s addView(View view, int position) method and
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