Posts by uaiHebert • 2,625 points
36 posts
- 
		1 votes1 answer877 viewsA: Leakage of connections with HibernateThe right way is to use some global solution for transaction control. I can remember 3 now: Using the Opensessioninview standard: This way you will have a Filterweb that when receiving the request… 
- 
		6 votes2 answers2937 viewsA: Best Way to Use and Instantiate EntitymanagerfactoryEntitymanagerfactory can and should be static: The specification says it’s multi-threaded Cost 'too loud' for you to instill it all the time In the class you created, leave the Entitymanagerfactory… 
- 
		0 votes2 answers458 viewsA: How do I move the A context session to B context within Tomcat 05Honestly I would go for a more programmatic approach, because the cluster configuration can influence much of the below. Use the approach of generating a token and save it to the bank. This way both… 
- 
		2 votes1 answer59 viewsA: How to persist the value returned by a method?I honestly don’t see any gain with this approach, but since you want a way out of this, use a method annotated with Prepersist. @Entity public class Entitidade() { private List<Pessoa>… 
- 
		2 votes1 answer281 viewsA: JSF cluster applicationIf you are using session Tomcat you should do something to share the session between Tomcat. An approach is called Sticksession where you define only one machine for a particular client and direct… 
- 
		2 votes3 answers474 views
- 
		8 votes3 answers5197 viewsA: Definition of EJBAbout EJB Quick Setting EJB is: "The guy to take care of the business rule". It was created to control the transaction, messages, project security, etc. The characteristics of the EJB are: Allow… 
- 
		2 votes2 answers2022 viewsA: Simple authentication example with level without Hibernate and springThe simplest way is with Filter. With the filter, which is already from java, you can intercept the request and validate whether a particular user is active or not. With the filter you can determine… 
- 
		3 votes2 answers1812 viewsA: Why compare Enum with an Enum ObjectWhen comparing as below, you can take a Nullpointerexception. Imagine what would happen if the value variable was null: if( valor.equals(TipoAlteracaoValor.ALTERACAO_VALOR) ) { System.out.println(… 
- 
		2 votes1 answer100 viewsA: Method not found using JPAThe Primefaces Autocomplete requires a String parameter. In your case it should be something like: lookupFornecedores(String valorDigitado){} 
- 
		1 votes1 answer148 viewsA: Software to query’s JPAIs there a way you can run your JPQL without needing a software for it: http://uaihebert.com/como-testar-sua-jpql-hql-sem-realizar-deploy/ You add a class that will create the JPA context in memory… 
- 
		3 votes1 answer2052 views
- 
		4 votes1 answer1708 viewsA: How to create a project with JSF, Primefaces, and Tomcat running in Eclipse and Netbeans at the same time?Create your project using Maven. Both Eclipse and Netbeans respect the Maven format so you can have both environments. This project here does not use JSF, but is done with Maven :… 
- 
		3 votes2 answers350 viewsA: Fetchtype.EAGER for Fetchtype.LAZYNatively there is no way to leave data as Lazy, yet. Below I suggest how to get around or live with this problem. Good Practice 1 Depending on the relationship there is no problem in leaving as… 
- 
		1 votes1 answer195 viewsA: Limit set size<> with JPANatively there is still no solution for this. If you are using Hibernate Session try using @Size or @Batchsize: @OneToMany(...) @Size(min=1, max=30) private List<Carro> carroList; or… 
- 
		3 votes2 answers1597 viewsA: Primefaces, button requires two clicks to perform actionYou are using ajax=false along with update, and that is wrong. Update is to be used with ajax=true or you don’t even need to write the ajax attribute. 
- 
		4 votes2 answers632 viewsA: Alternative to JPA ImplementationI would say that your problem is more related to how you use JPA than JPA as a problem. Eclipselink, Hibernate, Openjpa or Batoo will continue giving problem. With Java8 you will burst the memory… 
- 
		11 votes3 answers19566 viewsA: Customize the browser message for a "required" fieldYou can use HTML for this with the title tag: title="This field should not be left blank." If it doesn’t work with Firefox you can add: x-moz-errormessage="This field should not be left blank." You… 
- 
		2 votes3 answers166 viewsA: Form waiting for a requestSome points could be taken into consideration for an optimization: Does your table have indexes correctly created? If you make a query using LIKE and the table is large, without index, the… 
- 
		4 votes3 answers370 viewsA: How to perform TDD using HibernateYou have to understand the following, the cache is tied to the Persistencecontext that is created when you create an Entitymanager. You can easily use Junit with Entitymanager to test your DAO. What… 
- 
		4 votes2 answers1399 viewsA: Configure Hibernate transactions only with Jersey API AnnotationsNo, it is not possible to do with Jersey control Hibernate transactions. Understand that Jersey is made for REST communication and has nothing to do with Hibernate transaction. You could use CDI to… 
- 
		2 votes2 answers599 viewsA: How to make Hibernate "realize" that the value of a column was set by the databaseJPA/Hibernate only maps every change that passes through it. When making any change via database Hibernate is not aware that there has been such change. Actually, I would advise you to be very… 
- 
		1 votes4 answers775 viewsA: Static service class in web applicationYou could have your static methods without problem. You could do something like: public final class EmailHelper { public static void enviarEmail(Usuario usuario, Relatorio relatorio){ // seu código… 
- 
		14 votes3 answers15299 viewsA: Avoiding "!= null" comparison in JavaWhich code style to use? There are two types of programming that we can use: by contract or defensive. Contract programming is something more difficult to find out. It preaches that one should see… 
- 
		13 votes3 answers3943 viewsA: Alternatives to MVC for web applicationsMVC as Pattern? In fact I classify MVC more as layer splitting than a purely said Pattern. The MVC came to distribute responsibility between the layers of the project. It is very easy to add… 
- 
		9 votes1 answer1077 viewsQ: How to run a group of suites in Junit?I have the following suites below: @RunWith(Suite.class) // this other matters @Suite.SuiteClasses({ TestC.class, TestB.class, TestA.class }) public class MySuiteA {} @RunWith(Suite.class) // this… 
- 
		2 votes2 answers1021 viewsA: Processing of Session ObjectsUnfortunately many developers when working with JSF 1.2 log everything in. And a terrible practice. Take a look at this post: http://balusc.blogspot.com.br/2007/03/post-redirect-get-pattern.html It… 
- 
		2 votes1 answer693 viewsA: Client REST process JSON replay without knowing domain objectsLet’s simplify? Why don’t you apply the concept of KISS? Keep It Simple Stupid! I always try to apply this to my projects. If you don’t want to expose your domain classes why don’t you do something… 
- 
		4 votes1 answer3389 viewsA: How to upload Dynamic Images to JSF?Upload approaches There are two commonly used upload file saving approaches: saving to DB or to a folder off-project Error starting the project It is very common to see, who is starting to work with… 
- 
		73 votes5 answers6588 viewsA: Should error messages apologize?Caution when apologizing in an exception Apologizing for an error would not lead a user to most users thinking "Oh what cool, he knows the error was his"; an error message where the system admits an… 
- 
		6 votes1 answer1242 viewsA: Control module version with MavenIf all your projects are controlled in the same pom create a property: <project ...> <properties> <my.project.version>1.0</my.project.version> </properties>… 
- 
		5 votes1 answer3389 viewsA: How to receive a notification whenever there is a new record in a database table?Define an architecture If you want something portable between banks you should do in your system. Create a project pattern like: VIEW ---> Service ----> DAO (or Repository). The DAO would be… 
- 
		5 votes3 answers1353 viewsA: Architecture for a JSF Application with Android APPUsing Rest is the best solution. An architecture model that I know works is: Server(with business rules) <------- VIEW Note that no matter who the VIEW is, it will call the server and communicate… 
- 
		10 votes2 answers2459 views
- 
		17 votes1 answer11373 viewsA: How to use a specific index in a SQL Server query?You can run the query as below: SELECT CAMPO FROM TABELA WITH (INDEX(INDEX_LOTA)) And you can also add INDEX to a Join SELECT CAMPO FROM TABELA T WITH (INDEX(INDEX_LOTA)) INNER JOIN OUTRA_TABELA OT… 
- 
		5 votes5 answers2222 viewsA: Which libraries to develop a Restful API in JAVA?The Springmvc api is very good and simple to use. We use it here in the company throughout the project and can deploy with Tomcat/Jetty. Very light and simple. [= To give you an idea of how simple…