Posts by Josh • 1,436 points
39 posts
-
1
votes1
answer658
viewsQ: Change object in another method
What’s wrong with changing an object, which has been passed to another method ? , e.g.: public void doSomething(User user){ edit(user); //... EntityManager.persist(user); } public void edit(User…
-
1
votes1
answer785
viewsA: N-N relationship with additional fields (problems to persist data)
Responding to the discussion in the comments: Both the use of UUID(GUID) and ID have their pros and cons. The more technical details I leave to the original post, which this response is based on:…
-
5
votes1
answer822
viewsA: Implement serializable in JSF
In short, the class you inherit from the interface Serializable means that it can be serialized (in practical terms, the institution of the object of the class in question can be transformed into…
-
2
votes1
answer63
viewsA: Class relationship by collections in JPA2
This relationship would be better structured within a wrapper class for these two entities: @Entity public class Questao { @Id private int id; @OneToOne private Pergunta pergunta; @OneToOne private…
-
6
votes2
answers455
views -
1
votes1
answer220
viewsA: Competition problem in java web application
Your code contains some points, which deserve the following remarks: Do not use thread operations in a container, unless you are going to manage all of the Thread Lifecycle that you have fired…
-
3
votes1
answer373
views -
2
votes1
answer819
viewsA: How to deploy and run liquibase?
There are several ways to use Liquibase in your projects. It is possible to use the command line to generate, XML from an SQL and vice versa, there are other formats such as YAML, JSON, among…
-
6
votes1
answer2408
viewsA: Why should I use getResource()?
In short: getClass().getClassLoader().getResource("icon.png") //ou getClass().getResource("icon.png") will basically search for the resource even when your application is already packaged. However:…
-
1
votes3
answers1850
viewsA: How to test the Service layer in a web service application, using mockite and junit
Unit tests are only useful for testing the logic of a class or method. In this case you have a JAX-RS endpoint only, there is no logic there, nor is it advisable to have, this layer specifically…
-
3
votes2
answers909
viewsA: Convert List<T> to T... dynamically in a method call
This class method Class of the Java API receives a string and a Class<?>. The real problem then is to convert your List<Class<?>> paramsTypeClazz for varargs or an array. In this…
-
1
votes2
answers261
viewsA: Audioinputstream error ais = Audiosystem.getAudioInputStream(getClass().getResourceAsStream(s));
You can load the stream without problem here: ? bgMusic = new AudioPlayer("Resources/Musics/menu.mp3"); The path to the file seems wrong to me. In the end it will release a null Pointer Exception…
-
11
votes3
answers4376
viewsA: What is an N-Tier application?
Update: Tier usually refers to physical layer, while layer usually refers to the logical layer. This is an older concept, today basically, most servers run in the cloud, where this "physical…
software-architectureanswered Josh 1,436 -
1
votes1
answer306
viewsA: Object-relational mapping (JPA + Hibernate) using XML
Dude, hbm that I remember, they’re just specific filenames that Hibernate used for mapping... So in your case for example: Orm.hbn.xml that in the end is still your Orm.xml where you define all the…
-
2
votes3
answers3004
viewsA: Access data from already instantiated classes
Utilize getter / setters as for example, in a dummy variable minhaString defined within its User_info class: public class User_Info { private minhaString; public String getMinhaString(){ return…
-
1
votes2
answers551
views -
7
votes7
answers1478
viewsA: Is using many interfaces a bad programming practice?
Expensive if you have an interface for an implementation, I see no use having the interface. Many people use as an argument: "if you need to one day extend the class is easier", but that day never…
-
1
votes4
answers21058
viewsA: How to push local folder to Github
Only complementing the soaresfelipe response: git remote add origin <URL> will add the address to your remote Reposorios (which should be sufficient in your case). But, I advise you to use the…
-
2
votes2
answers2013
viewsA: How to pass a JSP file to Servlet?
Buddy, this is called file upload =) Here are some great references on the subject: Locaweb and codigofontes.com.br. Both have super simple code to understand, I have nothing else to add. Apart from…
-
2
votes3
answers474
views -
0
votes1
answer380
viewsA: Draw a line on Jlabel and Jpanel
In this case I advise you to use the Graphics2D. In fact I advise even refactoring the project and instead of using the components of Swing, draw yourself. But focused on solving the problem: Draw…
-
1
votes2
answers426
viewsA: Are Service Layer and BLL the same thing?
Both are complementary. Business layer is related to the logic of its application (validation and processing of information, for example). Service Layer is the layer where you can consume or provide…
-
2
votes1
answer94
viewsA: Nullpointerexception with CDI and JAX-RS
Friend, put more details of your Exception and also the structure of your project, is a . War ? a . Ear ? Anyway, and most likely you must have forgotten to add the beans.xml to your project, below…
-
2
votes1
answer94
viewsQ: Nullpointerexception with CDI and JAX-RS
I’m studying JAX-RS and created a simple project with the following class: Webservice @Path("generic") public class GenericResource { @Inject private MeuServico servico; @GET @Produces("text/plain")…
-
22
votes3
answers25678
viewsA: What is a Java Bean and what is it for?
Good did not get very specific about what exactly you are talking about, if the answer is not exactly what you need, please specify. What is and what a Bean is for ? In short: A class containing all…
-
10
votes4
answers5927
viewsA: Why split layers? What are the benefits of a multi-layered architecture?
N Layers are styles of architecture, MVC is a Pattern design. Many people confuse this. You can apply for example a 3-layer architecture together with MVC, in this case it would be the view layer.…
-
1
votes1
answer500
viewsA: How to test the creation of an obj and method call in a Servlet?
According to the Documentation: -Create a mock of your object to be tested Controle.class, for example: @Mock Controle controle; -In your test start and check if the method acao was called: public…
-
1
votes1
answer963
viewsA: Dynamic ng-repeat filter
Could you specify more your doubt ? is half vacant. If it really is what I understood, the solution below should solve: $scope.campoBusca= {campo1:'', campo2:''}…
-
1
votes3
answers5197
viewsA: Definition of EJB
Dude, I’m not gonna give you a giant answer, because there are already hundreds of sources: Wikipedia Oracle My answer: "Any class annotated with @Stateless, @Stateful or @Singleton that runs within…
-
1
votes1
answer402
viewsA: Stackoverflowerror exception occurring in @Manytomany relationship with JPA
Ricardo, you generated the methods toString(), hashCode() and equals() ? If yes, check how they are implemented, because in these cases there will be a circular reference within these methods,…
-
1
votes2
answers439
views -
1
votes1
answer203
viewsA: How to intercept only the public methods of a bean Managed?
You can use Interceptor. The problem is that they, as far as I know, don’t work with @Managedbeans, only with Beans through CDI and EJB. What can be done in this case is to change your bean to…
-
2
votes1
answer1836
viewsA: I can’t see console output on project with Wildfly
Application servers are a little more complex, and they use Loggers for that. The default output is not the same as a desktop app, for example. In order to be able to properly see this log you…
-
1
votes2
answers629
viewsA: Decrease space between two Jpanel in the netbeans prototyper
This is normal, and varies according to the layout manager you are using. If you want total control on your Swing components (Netbens) click with the right button on top of your Jframe and go to…
-
1
votes3
answers3039
viewsA: How to make a decision structure to close a window?
You have to use YES_NO_OPTION, try the code snippet below, which I took from an old project of mine. Any questions just return. Hug frame.addWindowListener(new WindowAdapter() { @Override public…
-
0
votes2
answers6870
viewsA: Jboss - "Unable to get Managed Connection for java:/Appds"
Friend, as stacktrace itself says... there was an error doing a "java:/Appds" lookup within its Notify class. You probably have something like this: (Oce did not clarify the details very well)…
-
5
votes2
answers1252
views -
2
votes3
answers1327
viewsA: Place information in field fields of a URL and send to the server with a program language
Amigo Httpurlconnection is a good way to start, but for practical purposes I advise you to take a look at this blog of Vogella: http://www.vogella.com/tutorials/ApacheHttpClient/article.html There…
-
0
votes2
answers451
viewsA: Specifying an EJB-client with Maven
It was not very clear your question, but from what I understand you are having problems with your EJB module interface in WAR... in this case change the pom.xml of your WAR module to the following:…