In my desktop application new databases get opened quite often. I use Hibernate/JPA as an ORM. The problem is, creating the EntityManagerFactory is quite slow, taking about 5-6 Seconds on a fast machine. I know that the EntityManagerFactory is supposed to be heavyweight but this is just too slow for a desktop…
Tag: java
API service works every second request
I have problem with jax-rs REST service. Service does not operate properly. Every second request service throw me exception: HTTP Status 500 – could not execute query type Exception report message …
Java – how to convert letters in a string to a number?
I’m quite new to Java so I am wondering how do you convert a letter in a string to a number e.g. hello world would output as 8 5 12 12 15 23 15 18 12 4. so a=1, b=2, z=26 etc. Answer Since this is most likely a learning assignment, I’ll give you a hint: all UNICODE code points
Error creating bean with name and Singleton bean creation not allowed
I am getting the following exception when I execute the code via JUnit Test Case org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name ‘somarFactory’: Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not requ…
Accessing non-visible classes with reflection
I am trying to get an instance of a non-visible class, AKA package private class, using reflection. I was wondering if there was a way to switch the modifiers to make it public and then access it using Class.forName. When I try that now it stops me saying I can’t do it. Unfortunately there is no setAcce…
Getting GPG Decryption To Work In Java (Bouncy Castle)
let me start by saying I’m extremely new to all of this. What I am trying to do is to use gpg from within Java in order to decrypt an encrypted file. What I’ve done successfully: Had a colleague encrypt a file using my public key and his private key and successfully decrypted it. Went the other wa…
ASM: how to easily get proper Opcode based on type
I am using ASM to generate Java bytecode. I have a need to create a dynamic proxy which can override basically any kind of method with additional post-processing. I am able to do it all, but there is one thing I can’t see how to do in a nice way. The type of the first parameter to the method I
Python very slow as compared to Java for this algorithm
I’m studying algorithms and decided to port the Java Programs from the textbook to Python, since I dislike the Java overhead, especially for small programs, and as an exercise. The algorithm itself …
An interface with different method parameters
I want to declare an interface be use with several classes this classes have method with different parameters interface: class A: class B: how to impelement of this interface? Answer you could make an operand-object or
Stackoverflow with Quicksort Java implementation
Having some problems implementing quicksort in java. I get a stackoverflow error when I run this program and I’m not exactly sure why. If anyone can point out the error, it would be great. si is the starting index. ei is the ending index. Answer First you should fix the bounds of the qsort recursive cal…