Posts by Dherik • 10,372 points
299 posts
-
0
votes1
answer64
viewsA: Data Modeling - Weak Entity
If I understand correctly, the teacher gave a another vision of what is a weak entity. We usually define whether an entity is weak or strong looking only to herself, but from what I understand the…
-
1
votes1
answer329
viewsA: Get into Webclient by passing json as parameter
You need to replace the \" for \\\": String url =…
-
4
votes4
answers542
viewsA: Is there a design standard or recommendation that defines the optimal amount of parameters a function should have?
The best known recommendation of limit parameters is from the book Clean Code in which the Daniel quoted in his reply. However, this perception is different among some authors and even among the…
-
2
votes2
answers592
viewsA: Spring Modelling JPA Person -> Personal Modelling -> Function
You can use the strategy of JOIN Single Table, where Hibernate creates a single table for each hierarchy. This is also the default strategy chosen by JPA if you do not explicitly specify one. For…
-
3
votes2
answers160
viewsA: Annotation @Scheduled Spring check environment
You can create a variable in a test property file to have its test properties separate from "default" (from the file application.properties) First, we will create the file in the following format,…
-
1
votes3
answers1106
views -
0
votes2
answers1478
viewsA: Spring Boot paging with custom SQL query method
See an example using Query and PageRequest, with a fictional entity called Pessoa where I use JPQL: public interface PessoaCrudRepository extends CrudRepository<Pessoa, Long> { @Query(value =…
-
3
votes2
answers418
viewsA: Spring - @Autowire a List with elements
The reason is simple. The builder of the class Rules is called before to inject the List<RegistrationRule> in the field allRules. Therefore, allRules will always be null. This would be the…
-
3
votes2
answers47
views -
1
votes2
answers246
viewsA: TDD with micro services
Unfortunately there is no silver bullet to solve this kind of problem in tests. Your solution works but is very intrusive to To, because to test the micro service B you need to know up to the micro…
-
0
votes1
answer387
views -
4
votes3
answers419
viewsA: What is the best strategy to load and persist large volumes of data with Spring?
Spring has a suitable tool for this, called Spring Batch. In a free translation: Many applications in the corporate environment require mass data processing to perform business operations in…
-
2
votes1
answer247
viewsA: What are the differences between mocks and fakes?
What types of tests (unit, functional, integration) work best with both? Are there specific situations where it is more evident that it is worth using one or the other? Examples in any language are…
-
0
votes2
answers113
viewsA: Classes with inheritance and set method
I wouldn’t recommend the set and yes the use of builders in your case. In OOP, it is usually clearer to use small classes and start objects through their constructors. Use set for all fields leaves…
-
-2
votes6
answers2089
viewsA: Check if a String contains two words
Gandalf, as you are learning, I took the liberty of tweaking the original code and running the necessary tests (very important). Look at the code: public static class NovoTeste2 { public static…
-
0
votes2
answers436
viewsA: Convert float value to String
You can use the class itself Float java: String s = Float.toString(25.0f);…
-
8
votes4
answers72185
viewsA: What is a callback?
But what is? A function of callback is that function that can be called by the method that receives it at the time it wishes. In a pseudo language, it would be something like this: funcao(Function…
-
3
votes2
answers103
viewsA: How to make an implicit conversion (inheritance) without losing information
You can simulate that in your database there are 3 tables (3 different ArrayList), one for each type of subscriber and each table needs to have a id, and the id theirs must be the same if they are…
-
1
votes3
answers910
viewsA: Encoding without configuration: Eclipse (JSP) and Vscode
If you are in English your Vscode, confirm that the configuration is correct: Go on File -> Preferences -> User Settings Add the input "files.encoding": "utf8" in the right window and save.…
-
2
votes1
answer91
viewsA: Class javax.annotation.Nullable not found
This class does not belong to Java 8. Therefore, you need a dependency external to may have it available in your project. If you are using Maven, you can add her this way: <dependency>…
-
1
votes2
answers43
viewsA: Doubt in the logic of the script
In your code you have two while. The while from the outside is executed before and its contents are executed as well. The code does not start with while internal, I believe this has confused you.…
-
2
votes2
answers101
viewsA: How to detect if the typed string has more than 6 characters?
You can do thus: senha = '123Mudar' # variável com a senha tamanho = len(senha) # calcular o tamanho da senha com a função len if tamanho > 6: # verificar se a senha é maior que 6 print("Senha…
-
1
votes3
answers464
viewsA: drop table with temporary table giving error
You need to use the command: IF OBJECT_ID('#tempCID') IS NOT NULL DROP TABLE #tempCID However, for this to work in Delphi, you need to use the following String, escaping single quotes with another…
-
2
votes2
answers1499
viewsA: Java DTO with Spring Boot 2
You need to do the cast of ClienteDTO for PessoaFisicaDTO or PessoaJuridicaDTO before picking up the attributes, imagining that an instance of each actually arrives in your method. Example: public…
-
21
votes2
answers5722
viewsA: What’s wrong with the N+1?
But what’s really this problem The best way to explain this problem is with an example. Imagine you have a table Pessoa and a table Endereco. Each person has several addresses, consolidating a list…
-
0
votes1
answer210
views -
9
votes2
answers4147
viewsA: What is the difference between Embeddedid and Idclass in Hibernate?
Are two ways to make the representation of the composite key in the entity. Let’s say you have a table parametro, entity Parametro and its composite key is nome and empresa. The table can be as the…
-
1
votes1
answer62
views -
8
votes1
answer632
viewsA: How to delete a file from all commits?
You can use the filter-branch for this. First, you need to track the commits that contain this file: git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch…
-
2
votes1
answer145
viewsQ: Initialize and change static variable in a thead safe way. Does this code make sense? Intellij IDEA doesn’t think
Hello! I’m looking for a safe way to boot and change a static variable that will be shared by different threads that will be accessing its value. The idea is that, at some point, I will verify that…
-
7
votes4
answers12289
viewsA: Indent HTML code in Notepad++
You can use the XML Tools. Install XML Tools from Plugin Manager. Use the shortcut Ctrl+Alt+Shift+B (or Menu -> Plugins -> XML Tools -> Pretty Print)…
-
2
votes6
answers1694
viewsA: Why not use a Boolean parameter?
It is not possible to generalize and define any parameter boolean is a problem. Whether it is a problem or not, it will vary from the objective, context or even size of the method/class that is…
-
2
votes1
answer285
viewsA: View all Intellij projects created
Eclipse has the concept of Workspace, where you can import multiple projects to the same Workspace and view all of them at the same time. Intellij IDEA has an alternative that does not have the…
intellij-ideaanswered Dherik 10,372 -
1
votes1
answer46
viewsA: Remove objects that are attached to the list of others
Yes. You need to remove the option of cascade amid Procedimento and Setor: @ManyToMany(mappedBy="procedimentos", cascade = CascadeType.ALL) Or change it to the scenario that best fits your case. As…
-
1
votes1
answer61
viewsA: I can’t generate the RSA key for Github: "Too Many Arguments"
Probably a detail in the command. Instead of using -c (c letter in lower case) use -C (uppercase letter C). Also correct the command and leave the e-mail in quotes. The final command should look…
-
2
votes5
answers2767
viewsA: HTTP methods in practice
Hello, I’ll try to get to the point, answering only your questions. Which method will I use for authentication? The method is usually used POST. Certainly authentication is a concept that does not…
-
2
votes1
answer562
viewsA: How to optimize Hibernate query
Yes, there is. There are several ways. The most popular is to create a specific class to receive only the attributes you want. This class is instantiated within the HQL itself and you pass to the…
-
1
votes2
answers364
viewsA: Control of Rest application transactions in spring
It is a matter of responsibility, which in turn reflects on flexibility and avoids several other problems. The Controller should know nothing about the database, let alone open a transaction with…
-
0
votes1
answer180
views -
0
votes1
answer692
viewsA: jpaRepository + JPQL + JOIN
Understanding that the entities Table 1 and Table 2 do not have a relationship with each other, and you just want to make a JOIN between them, we can do this via WHERE: @Query(value = "SELECT tab2…
-
1
votes1
answer146
viewsA: Problem when merging
If you’re seeing one file with the right accent and another with the wrong accent in the same merge, it’s probably not a problem with Git. Git can change the form of file lines breaking (CRLF vs…
-
1
votes1
answer38
viewsA: In this case below, wouldn’t the login attribute have to be set as private for the method?
Without a context about the problem, it’s hard to say with precision. But looking only at the code, I understand that at the time of authentication you will perform a comparison between the values…
-
0
votes1
answer167
viewsA: What databases is Apache Atlas compatible with?
For what I understood, Apache Atlas uses the Hbase and only him, since Apache Atlas uses Hadoop and Hadoop’s database is Hbase. You can choose between using an external Hbase or using an Hbase…
-
15
votes1
answer346
viewsQ: What is the alternative of 'And' in Portuguese for variable names and methods?
One question that always bothers me when I’m in a Java project where we use Portuguese terms is dealing with method names or variables that represent, somehow, two things and I need to mention both…
-
1
votes1
answer1361
viewsA: Repository not found when starting Springboot
There are different reasons for this error to occur. The most common is when your class noted with @SpringBootApplication stays in a package (or module) different of Repository. For this, you need…
-
5
votes1
answer52
viewsA: Publishing packages in the NPM repository
According to the official documentation, these are the steps: Create an account on NPM Revise the code Review the files that need to be sent See if your package.json follows the appropriate…
-
2
votes2
answers822
viewsA: Make a consultation with Ibernate criteria with Spring
You need to add one JOIN between Proposal and Client, in this way: // veja que adicionei um alias chamado "proposta" Criteria criteria = manager.unwrap(Session.class).createCriteria(Proposta.class,…
-
9
votes2
answers12870
viewsA: How to consume an external API in Spring Boot
You can use the Resttemplate for this. As an example, imagine that you want to do a GET for the system at the address www.sistema.com/api/ in the service of pedidos identifier equal to 10. You will…
-
1
votes1
answer427
viewsA: I switched the hard drive and I can’t re-open the project
Right-click on the empty project and choose the option to Reload or Add existing project. One of these options will be enough to solve your problem. PS.: I tried to guess the translation of the…
visual-studioanswered Dherik 10,372 -
5
votes3
answers2113
viewsA: Why use Git for individual development?
Rodrigo’s response brings several advantages of Git, so my answer goes more as a complement, trying to cover some other points. I understand that Git turns out to be the default option even for…