Posts by Gustavo • 635 points
28 posts
-
0
votes1
answer76
viewsA: How do I work with chained Hashmap in Java?
The problem is that the url is not found in the parent node. The URL is inside the Node photo.images.small or in photo.images.thumbnail or photo.images.original, etc.. Take a look at this solution:…
-
0
votes1
answer58
viewsA: my Boolean does not respond , what should I do?
Vc has a global variable called player which is null and is the variable being used in the method keyPressed() public Game(){ ... Player player = new Player(0,0,16,16,spritesheet.getSprite(32, 0,…
-
0
votes1
answer101
viewsA: UML - Composition or Aggregation
There is not only an always correct answer in this case. Everything will depend on the business rule, how it should be structured. If your business rule specifies that controleCurso MUST HAVE one…
-
1
votes1
answer121
viewsA: How to query within a Java array?
1) Comparison between Strings; The main problem is that you are making the comparison with ==. The comparison between Strings should be made with .equals which makes the comparison by value and not…
-
3
votes1
answer3128
viewsA: Error 'Noclassdeffounderror: org/springframework/boot/context/properties/Configurationpropertiesbean'
The class ConfigurationPropertiesBean is not being located. The class was released from version 2.2.0 of Spring (class documentation) and looking at your stackTrace you seem to be using version…
-
1
votes1
answer368
viewsA: Spring Boot + JPA + Websecurity - How to save User + Profile?
Add the association between tables. PROFILE CLASS @Id private Long id; @ManyToOne(fetch = FetchType.EAGER) @GeneratedValue(strategy = GenerationType.AUTO) @JoinColumn(name = "usuario_id") private…
-
2
votes1
answer127
viewsA: How to read String in the best way to use it as a halting condition of a loop?
The comparison with == and != does not compare the contents. Comparing strings should be done with strcmp. Substitute: do{ inicializando(); printf("\n\n - Deseja fazer um novo calculo? (S/N): ");…
-
4
votes1
answer463
viewsQ: How to schedule a task and run only once independent of the number of instances?
My application has a scheduled method to run every 5 minutes with the @Scheduled of Spring, but I would like to rise more than one instance of implementation and that this task should not be carried…
-
-1
votes1
answer91
viewsQ: How to reduce Page return fields in an API?
I am implementing pagination in some endpoints of my API and the return is a Page. This object returns many arguments, there is some way to eliminate some of them? The Repository extends…
-
2
votes1
answer1199
viewsA: How to Map One to Many Correctly in Hibernate
Put the entities relationship in the statement: TEACHER CLASS @Entity public class Teacher { @Id @Column(name="teacher_id") private int id; @Column(name="teacher_name") private String name;…
-
0
votes1
answer64
viewsA: Sorting algorithms - How to discover comparisons and drives
The numbers of comparison and movement are always the same because you only add it when you enter the if. If vetor[j - 1] is greater than vetor[j] it does not enter the if, so it does not add in the…
-
0
votes1
answer77
viewsA: Please help - Exception in thread "AWT-Eventqueue-0" java.lang.Numberformatexception
The exception itself already indicates what is happening: trying to convert a String to Float, but the String is not valid. The String you are trying to convert is "199.67" but Float doesn’t know…
-
2
votes1
answer643
viewsA: How to browse a java chained list
You can’t go through the list of doctors because you’re accessing the object Medicos who is in your ListaSimples and not the doctors of each node. No need to create a doctor in your class…
-
2
votes1
answer1387
viewsA: Spring Boot, ultilizar outro campo de busca além do @id
Your Repository should be able to search in the bank by CPF, thus: @Repository public interface PacienteRepository extends JpaRepository<Paciente, Integer> { Optional<Paciente>…
-
1
votes1
answer183
views -
0
votes1
answer67
viewsA: Javamail: Mailbox always downloads the same email
When you perform Message[] messages = emailFolder.getMessages(); it returns ALL Folder messages, which in your case is INBOX, which is why it always brings the same messages. You can solve the…
-
0
votes2
answers332
viewsA: User change does not work, is doubling given in bank
In case of a change, you need to recover this record in the database first. Create a change method that retrieves the user in the database and then save the change. For example: @Service public…
-
0
votes0
answers59
viewsQ: Does Jparepository Saveall maintain the state of persistence in memory?
Jparepository offers us options save and saveAndFlush to persist the objects to the database. Unlike saveAndFlush, the save keeps the persistence state in memory, which ends up generating memory…
-
1
votes2
answers962
viewsQ: Validating null and/or empty fields when creating Java objects
I have an object and would like to force the filling of attributes at the time of the creation of the object. What is the best way to do this? There are the annotations @NotNull, @NotEmpty and…
-
1
votes0
answers666
viewsQ: How to test one method that depends on the result of another with Junit?
Greetings, I have a class that does actions in an email. I created some tests for this class and would like to know if this is a valid form of testing or if there is any better way to do it. I test…
-
0
votes1
answer90
viewsA: About implementation using spring
Greetings, You need to create a Repository for Pessoas tbm: @Repository public interface PessoasRepository extends JpaRepository<Pessoas, Integer> { } This way you will use this repository to…
-
2
votes2
answers1169
viewsA: Exception error in thread "AWT-Eventqueue-0" java.lang.Nullpointerexception
You stated resultados and resultSet as null in class ProdutoDAO and they are not being initialized. List<Produtos> resultados = null; ResultSet resultSet = null; And besides, it is missing to…
-
1
votes2
answers143
viewsA: Clone a list in Java
Hello, You want to clone the list for a test class, but if you make an instance of your class Gerenciador in your test class you will have list without the need to clone it. I believe that it was…
-
0
votes1
answer72
viewsA: Return/save problem in a JAVA list
Hello, In your main method you are passing an empty list in the method call Imobiliaria.ListarDisponivel(lista1); and it is on top of that list that the class method Imobiliaria is working. The list…
-
1
votes1
answer371
viewsA: Table relationship - Spring Boot Hibernate: Error accessing field [private int
Hello. It’s a little difficult to visualize the error by Postman’s reply message and without all entity classes, but let’s go. Try to replace your relationship mapping to the following way: @Id…
-
0
votes1
answer37
viewsA: Error changing record in table
Good afternoon, I think you could put more of your code. The whole method, for example. But apparently you are trying to save or update a vehicle registration with an associate registration that…
-
0
votes1
answer73
viewsA: Primary Key: Hashmap or Common Object?
You can create your object with the fields normally and then create the composite key with the fields you want. In your case, you would create "machine type" and "number" and then write down both to…
-
5
votes2
answers1055
viewsQ: If, Elseif and Else with Java 8
I would like to build a method using Java 8, replacing the conditional IF, ELSE-IF and ELSE. For this, I built a sequence of code, I do not know if it is ideal and would like to hear better opinions…