Posts by Caffé • 17,429 points
254 posts
-
3
votes1
answer177
viewsA: Identify an Object property in Java+JPA and change it
You can search for the attribute (here represented by the class Field) which has the annotation @Id. Once found, you use the method Field set. of the attribute itself found to set its value to null.…
-
8
votes3
answers15702
viewsA: Difference between private final and private final Static for the use of immutability
There are some false premises in your question: "In both the instructions [Static and final] we achieve the same goal, that of making the value of an unchanging attribute." The objective of Static…
-
3
votes5
answers2024
views -
30
votes1
answer41651
viewsA: Format value with Brazilian currency mask
You can use the string. Format, passing the format C (currency): <td> <asp:Label ID="lblCreditoCota" runat="server" Text='<%# string.Format("{0:C}", Eval("CreditoDisponivel")) %>'…
-
3
votes1
answer1178
viewsA: How to filter a SELECT with n:m and bring all characteristics?
Select over the link table between products and attributes so as to repeat a product as many times as it has different attributes. The filter that decides which product the attributes will be…
-
6
votes5
answers1879
viewsA: What is the difference between an explicit cast and the operator as?
In addition to the explanations already given of which cast ((TextBox)sender) exception while as (sender as TextBox) returns null if the types are not compatible, two remarks: Using one or the other…
-
1
votes1
answer189
viewsA: How to ensure that all threads have run?
Using Futuretask you don’t need a loop to check if you’re done. You also don’t need a specific method to wait to finish. The method itself get does both - waits to finish and then gets the computed…
-
1
votes2
answers2804
viewsA: How to pass commands to a . exe via C#?
Here you don’t have the full answer but a kick start. User entries (which you want to simulate) are sent to a form (in practice, a Windows window that contains many other windows) through a…
-
2
votes1
answer335
viewsA: Identify path or letter of DVD drive in autorun
If the application is on the same drive as the other application that will be fired, you can identify the drive of your application and then form the complete path of the second application. For…
-
3
votes3
answers353
viewsA: How can I split this INSERT into steps?
You can use the two parameters allowed in the clause LIMIT, where the first indicates from which line you want to read (indexed at zero). Thus, the first query remains the same, rescuing up to…
-
4
votes1
answer269
viewsA: Error importing DLL
"TLB"? Then he is trying to consume his DLL as an Activex component. The problem is that the WITH does not support static methods and when your colleague creates the proxy for your DLL the static…
-
12
votes3
answers5311
viewsA: When to use var in C#?
At the beginning, the documentation of the Microsoft included a note saying that excessive use of var when not needed could impair the readability of the code. Then Microsoft removed this paragraph.…
-
1
votes2
answers357
viewsA: Base62 coding
You cannot have something represented in Base64 with just this character range (A-Z, a-z and 0-9) as this range has only 62 characters and Base64 requires 64 distinct representations. So if you…
-
4
votes1
answer1336
viewsA: How to get the next ID to be inserted?
This is a fairly common need and in other databases is solved with SEQUENCE. Sequence is different from auto increment because using Quence you (or the framework or database through a Trigger) first…
-
1
votes1
answer209
viewsA: IF in Storedprocedure within a select, remove sp_executesql @query
You can always keep the condition in the query, including a OR for the parameter; this eliminates the IF. It goes something like this: ...AND (@IDCorretor = 0 OR tbl_imoveis.int_CORRETOR =…
-
6
votes3
answers1408
viewsA: Working with JPA+Hibernate cache
Some methods of acquiring entities rescue the entity from memory if it is already there, and not from the database. For example, you seek a person: pessoa = entityManager.find(Pessoa.Class, id);…
-
2
votes1
answer2941
views -
0
votes4
answers6781
viewsA: Why does my CNPJ validation pass this invalid value?
Although there is no CNPJ or CPF with all digits repeated, the official logic of validating the check digit of these documents declares them as valid. Note that not only a sequence of zeros will…
-
4
votes2
answers952
viewsA: Enum as Hibernate Parameter Namedquery
You can pass parameters to a named query the same way it passes to any JPA query. Using standard JPA, prepare the query to receive the parameter: @NamedQuery( name="findAllGastos",…
-
4
votes2
answers1286
views -
4
votes2
answers740
viewsA: Why is Ajax only working the first time?
The way you add code to the controls event ($('#ocultaLancamento').click(function(){...) will cause this association to be lost when component is recreated, and the component is recreated if it is…
-
1
votes2
answers501
viewsA: Error canceling file import in Excel
Your comment explains that "cancel" is about the user canceling the dialog box that asks for a file to be selected. In this case where the user decided not to import the file, you must "skip" the…
-
5
votes1
answer262
viewsA: Access Violation when creating Thread
Where you wrote DownThread := DownThread.Create(True); the correct is DownThread := TMeuDownloader.Create(True); Note the difference: in your code you call the method Create from the variable…
-
4
votes1
answer83
viewsA: I can’t perform a Select
You don’t need to involve the table Tab_client in SELECT because you will not fetch any data from it. You need to get the authorization codes from a customer in the table Tab_cliente_authorized and…
-
2
votes1
answer1433
viewsA: Problems with NOLOCK, READ COMMITTED SNAPSHOT
Versions of Microsoft SQL Server prior to 2005 did not have the feature of SNAPSHOT, then the hint WITH NOLOCK could actually improve performance by making a query (a SELECT) not wait for the…
-
1
votes2
answers623
views -
1
votes1
answer71
viewsA: Report Error while copying files and folders using Threadpool
You’re making some mistakes in your code - for example by throwing an exception inside a thread and hoping to catch it in a catch outside of it (that’s not how it works). The code below is almost a…
-
1
votes4
answers428
viewsA: Make SELECT return data in default language when no translation can be found
You can search for the desired language (en-us) or the default language (en) case the desired language is not present. For this last condition you can use the clasp not exists about a subquery…
-
2
votes4
answers964
viewsA: How to do advanced data filtering across multiple fields?
The query below returns the records where each field is either equal to the parameter or is null. The function find_in_set Mysql does the trick of searching for a value in a comma-separated text…
-
3
votes1
answer46
viewsA: Replace in Date inside a FOR
Keeping your algorithm, add this line that will set in @Data_Atual the first day of the month itself @Data_Atual: SET @Data_Atual = DATEADD(month, DATEDIFF(month, 0, @Data_Atual), 0)…
-
10
votes3
answers4171
viewsA: Time in Java counting seconds in real time
You can use the Java service scheduler to display the hours every second. import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.*; public…
-
2
votes3
answers5509
viewsA: What’s the difference between using Inner Join or Where relationships
Database servers provide resources for you to analyze how they will perform the query. Examples: Microsoft Sql Server Execution Plan Mysql EXPLAIN Oracle EXPLAIN PLAN These features show what the…
-
3
votes2
answers814
viewsA: SQL function that applies to each row of the column
In Microsoft SQL Server, you can join with the result of a function whose return is of the type TABLE (like your). I suggest working with specific date type and functions, as recommended by…
-
2
votes3
answers254
viewsA: Why validate even with a default value
We need more meaningful code instead of more code When the code is very expressive, it’s easier for programmers to know what to expect from it. This lessens the fear that leads us to add more and…
-
21
votes3
answers8663
viewsA: What is the difference between DOM and virtual DOM?
Difference between DOM and Virtual DOM GIFT is the representation of the components on the page. You manipulate the DOM in order to manipulate these components (create, recreate, change their…
javascriptanswered Caffé 17,429 -
2
votes1
answer1978
viewsA: Page does not load Primefaces components
In fact the Primefaces components were created, or you would have other symptoms. What occurred was that the styles were not applied. The Primefaces adds references to your (css) style libraries in…
-
10
votes3
answers660
viewsA: Should we validate function parameters?
My answer starts with a question: what benefits you see in this practice? You have listed two points that you consider negative and have listed no benefits. In Javascript, throwing an exception for…
-
5
votes1
answer47156
viewsA: Run oracle Procedure
The process expects 2 parameters but you are passing only one parameter to it. To pass an output parameter to a stored Oracle database, you can do so: declare P_ID_CARTAO number; begin EXECUTE…
-
2
votes2
answers178
viewsA: Does PHP work within Javascript?
Javascript runs in the browser while PHP code runs on the server. What you can try to do is create Javascript code while the page is being created by PHP. One option is to print the values of the…
-
8
votes4
answers1574
viewsA: Database and transaction control in value transactions
Let’s say that building the balance from reading all transactions is in fact a Constraint for performance (you don’t know yet, but let’s say you already know), you can create a table to maintain the…
-
7
votes5
answers22737
viewsA: How to turn the output of a command into a variable in CMD?
One option is to use Windows Powershell, which can be seen as a more modern and powerful Windows command prompt (cmd)). Example To set the output of the command in a variable mountvol, passing…
-
1
votes1
answer197
viewsA: Using Gfix in a C#
This example demonstrates how, from C#, run a program / external application and read the output or results of this program. The code below triggers the Windows command prompt (cmd.exe) and passes…
-
6
votes2
answers7173
viewsA: Firebird SQL auto-increment
No, Firebird offers no other way to implement auto-increment column other than this. Eventually you can use other Firebird features and invent another way, but the shape offered by the tool is this.…
-
0
votes2
answers290
viewsA: Recovering List of Outdated Objects with Hibernate
You are making the refresh of each object Praga, this causes a given object to be updated with the state of its attributes in the database, but does not cause all objects of that type to be updated,…
-
6
votes3
answers4278
viewsA: Create a class dynamically in C#
The code below defines in Runtime a ClasseB you inherit from your ClasseA, where I added private fields to use in the properties instead of leaving it to the compiler. The approach I used to ClasseB…
-
4
votes3
answers527
viewsA: Structure/Nomenclature of Tables
Dealing only with what we have there, what it seems to me is that you want to create a group and add to it permissions of other existing groups; and the same for systems. I believe this language…
-
1
votes2
answers438
viewsA: How to give ALIAS with current "month/year"?
It is not possible to define an alias dynamically. SQL is not your friend when it comes to getting columns from the database that you do not know what they are. Consider creating a stored Procedure…
-
64
votes4
answers42803
viewsA: What really is DDD and when does it apply?
What is DDD? Domain-Driven Design (DDD) is a software development approach where design is domain-driven, i.e., the area of knowledge to which the software applies. Another way of saying is: in DDD,…
-
9
votes3
answers2984
viewsA: How to name a unit test when using TDD?
Your question deals with two aspects of method naming; semantics and formatting, so to speak (classifications that I have just come to think of). Formatting The issue of formatting is simple:…
-
3
votes1
answer778
viewsA: Java/ Sqlserver transaction divided into multiple methods
If you want the invoked methods to execute their SQL commands within the same transaction opened by the main method, they must use the same connection opened by the main method. You have to pass the…