java-ee

Best (most efficient) DataType to use for UUIDs as JPA IDs

时光总嘲笑我的痴心妄想 提交于 2019-12-23 18:17:59
问题 I want to use UUIDs as IDs for my JPA Objects. I am currently just using a String to store the UUID. What would be more efficient? 回答1: How are you measuring efficiency? For example, storing the UUID (which is a text encoding of a byte[] ) as a couple of long values will allow you to compare them very quickly on a 64-bit architecture (much more quickly than String comparison, which is character-by-character). However, your coding efficiency would suffer, because you have to write a custom

Injection of autowired dependencies failed

与世无争的帅哥 提交于 2019-12-23 17:26:20
问题 I'm using Spring and Hibernate in a Java-EE application. The project is hosted at this GitHub repository. I'm having problems using `@Autowired through the Service like this: package no.niths.rest; // Imports ... @Controller @RequestMapping("courses") public class CourseController implements SimpleREST<Course>{ @Autowired public CourseService service; } And the respectice Service: package no.niths.services; // Imports ... @Service public class CourseService { @Autowired public ICourse repo; }

jax-rs ContextResolver<T> undestanding

泪湿孤枕 提交于 2019-12-23 17:17:48
问题 But I was trying to understand the usage of Providers in jax-rs. But was not able to understand how ContextResolver can be used. Can someone explain this with some basic example? 回答1: You will see it being used a lot in resolving a serialization context object. For example an ObjectMapper for JSON serialization. For example @Provider @Produces(MediaType.APPLICATION_JSON) public static JacksonContextResolver implements ContextResolver<ObjectMapper> { private final ObjectMapper mapper; public

What is the difference between CacheStoreMode USE and REFRESH

瘦欲@ 提交于 2019-12-23 17:17:46
问题 The javadocs for CacheStoreMode differentiate in a point I cannot really grasp: The javadocs for the USE mode: Insert/update entity data into cache when read from database and when committed into database: this is the default behavior. Does not force refresh of already cached items when reading from database. The javadocs for the REFRESH mode differ in the last sentence: Forces refresh of cache for items read from database. When an existing cached entity instance is updated when reading from

Passing value from servlet to html [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-23 17:14:43
问题 This question already has answers here : Generate an HTML Response in a Java Servlet (2 answers) Closed 3 years ago . I have a servlet that processes some content from the web and generates a String value. I need to display this String value in a html page within a table tag. How do I pass this string value from servlet using the setAttribute method and getrequestdispatcher method? Thanks Abhishek S 回答1: You can pass the data from servlet to JSP (not HTML) using request forward and by setting

What is the difference between CacheStoreMode USE and REFRESH

我与影子孤独终老i 提交于 2019-12-23 17:13:08
问题 The javadocs for CacheStoreMode differentiate in a point I cannot really grasp: The javadocs for the USE mode: Insert/update entity data into cache when read from database and when committed into database: this is the default behavior. Does not force refresh of already cached items when reading from database. The javadocs for the REFRESH mode differ in the last sentence: Forces refresh of cache for items read from database. When an existing cached entity instance is updated when reading from

Java ee interface conditional inject

狂风中的少年 提交于 2019-12-23 17:10:16
问题 I have the following interface: public interface ResultEvaluationInterface { public void evaluateResults(Event e); } and I want to inject in my class depending on my Event.type different classes with the same implementation. Something like that: @Stateless @LocalBean public class ResultEvaluation implements ResultEvaluationInterface { @Override public void evaluateResults(Event e) { switch (e.getType()) { case Type.Running: // inject and call ResultEvaluationRunningEJB.evaluateResults(e) case

Use custom JRE for Wildfly 10

帅比萌擦擦* 提交于 2019-12-23 16:53:30
问题 Can I choose a custom JRE for a Wildfly Application Server with a property like standalone.bat -Djava.jre=<path> For my project, it is important that I can't change the value of parameter JAVA_HOME 回答1: You can set the JAVA_HOME used by WildFly. For Linux/UNIX, check the standalone.conf file: # Specify the location of the Java home directory. If set then $JAVA will # be defined to $JAVA_HOME/bin/java, else $JAVA will be "java". # #JAVA_HOME="/opt/java/jdk" For Windows, check the standalone

static block is called twice, maybe multiple class loaders?

痞子三分冷 提交于 2019-12-23 16:15:59
问题 I have an MDB EJB, with static block inside it. I used the static block to initialize some components only once at the first time the application runs (i.e at deployment). The MDB EJB is deployed on a separate sever (My_Server) other than the Admin_Server. The problem is that the static block is called twice! The first time: just after deploying the MDB EJB (tageted to the My_Server). The second time: after the JMS queue (that the MDB is associated with) receives a message. Also, I printed

Java Jersey RESTful web service using https

∥☆過路亽.° 提交于 2019-12-23 16:15:37
问题 I am new to Java EE and I am developing a RESTful api in wich every api call the user sends encoded credentials. My problem is how to implement https protocol over default http and make my connection secure. I am using Jersey restful web services and Glassfish web server. Thanks. 回答1: That's more a setup/configuration question, isn't it? You use HTTPS (TLS) because you set it up in your server, then your REST endpoint will be used/changed accordingly...and the (encoded) credentials can be