Angular and Updates
Random Thoughts on Java Programming
by
1w ago
Recently was interested if and when Angular upgrades to a new release, as I found myself skipping release 17, and the update process can be a tiny bit troublesome if you skip a major version. Angular has Semantic Versioning, and releases a new major version every 6 months. Angular 19 will possibly be out and about end of November 2024. Luckily, from the references below, there's some things that I can hold on to: a major version may require a bit of work by the developer. a minor version can be installed without problems immediately. No developer assistance is expected during update. However ..read more
Visit website
Kotlin: The Spead Operator
Random Thoughts on Java Programming
by
1w ago
Recently ran into a brick wall trying to pass a varargs parameter to another function that also has a varargs parameter. A colleague mentioned the "spread" operator to me and it took me a little while to find information about it. An example package org.mrbear.kotlin enum class ErrorCode(val description: String) { OBJECT_NOT_FOUND("Object %s not found."), NO_DEFAULT_PROVIDED("No default provided for parameter %s."), MALFORMED_URL( "Malformed url (%s)" ) } abstract class MyException : Exception { constructor(errorCode: ErrorCode, cause: Throwable, vararg params: Any) : s ..read more
Visit website
Upgrading to Angular 18
Random Thoughts on Java Programming
by
2w ago
Upgrading Javascript things is always a chore. That's why these blogposts keep appearing. % ng version _ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | | / ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | | /_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___| |___/ Angular CLI: 16.2.5 Node: 18.16.1 Package Manager: npm 9.7.2 OS: darwin x64 Angular: 16.2.8 ... animations, common, compiler, compiler-cli, core, forms ... locali ..read more
Visit website
Caching REST Resources In Jakarta REST
Random Thoughts on Java Programming
by
2M ago
I found the following blog post on caching interesting. See reference [1] I like caching, but I understand there's a very real danger of seeing outdated results. The Blogpost highlights this quite good. HTTP Caching has several great options, apparently: Expired Header (HTTP 1.0) - ResponseBuilder.expires Cache-Control Header (HTTP 1.1) - CacheControl class for more control ETags - EntityTag class, indicates a kind of hashcode to verify if a Resource has changed, without actually accessing the resource Nice. References [1] Caching REST Resources In Jakarta REST (formerly JAX-RS) https://blog ..read more
Visit website
Stream.sorted() - For unordered streams, no stability guarantees are made.
Random Thoughts on Java Programming
by
3M ago
So I was writing code, and I had to sort a stream, because originally I had a Set, and everyone knows Sets are unordered by default. But my eye fell on the javadoc on .sorted(). To be more specific: For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made. And the sentence kind of made me nervous. Example An example of an unstable sort is visible in the unit test below. The unit test will sometimes pass and sometimes fail. The reason for this is that Ken Thompson and Simon Thompson are equivalent in the sorting and, as it is an unsorted stream to begin w ..read more
Visit website
Migrating Oracle to PostgreSQL
Random Thoughts on Java Programming
by
5M ago
So at work we're currently trying to see if we can move away from Oracle and onto PostgreSQL. I expect this to be a long process. This blog post is here to document some of the issues we ran into and also remember references I found. Migrating schema and data There are several tools that can migrate the schema and the data from Oracle to Postgres. There are some differences in what both database support. See reference [1]. Make changes to SQL Scripts References [1] Hackermoon - How to Migrate from Oracle to PostgreSQL https://hackernoon.com/how-to-migrate-from-oracle-to-postgresql Postgres Wik ..read more
Visit website
SQL: Concat operator and Spaces
Random Thoughts on Java Programming
by
7M ago
So I had a pressing need to query my database and concatenate several values from a row together (using either concat or ||), but with spaces in between. But I don't want two spaces if the value in between is empty. It is surprisingly difficult to do in SQL, but there are some options available. First the data: TITLE FIRSTNAME MIDDLENAME FAMILYNAME Ichabod Crane Dr. Thomas Lancaster Philip Martin Brown select TITLE || ' ' || FIRSTNAME || ' ' || MIDDLENAME || ' ' || FAMILYNAME from PERSON; So, if you use the SQL statement above, you get the problem, extraneous spaces. For example ..read more
Visit website
The DUAL table
Random Thoughts on Java Programming
by
7M ago
I'm working with Oracle databases (version 19 for now), and I always wondered about the weird DUAL table1 that I require in my work. Things like this: select sysdate from dual; select seq_s_ordertable.nextval from dual; Well, apparently we have Charles "Chuck" Weiss2 to thank for it. One of the reasons is that the FROM clause in Oracle SQL syntax is mandatory. Interestingly, Charles originally created the DUAL table with two rows, hence the name DUAL. Nowadays it's one row, but the name's stuck. It's part of the Data Dictionary of the SYS user. Changing the DUAL table will cause problems!3 Ref ..read more
Visit website
Using Java to Zip/Unzip files
Random Thoughts on Java Programming
by
7M ago
There's been a ZipFile class in Java sinds a long time. But nowadays sinds JDK7 there's also a ZipFileSystem which is a bit easier to work with in some cases and can do more things. Below are two examples, one using ZipFile and one using ZipFileSystem. Using ZipFile Unzipping works as follows: @Test public void testOldZip() throws URISyntaxException, IOException { URL resource = UnzipperTest.class.getResource("/test.zip"); assert resource != null; Path path = Path.of(resource.toURI()); try (var zipFile = new ZipFile(path.toFile())) { Enumeration<? extends ZipEntr ..read more
Visit website
Streams and Filters
Random Thoughts on Java Programming
by
8M ago
A simple little thing. I like to use streams and filters, and I was wondering what's the best way to go about some things. For example: I wish to search for a person in a list of Persons. @Test public void testSimple() { Person personToFind = new Person(null, "Mr.", "Bear", "Netherlands"); Person otherPersonToFind = new Person(null, "Linda", "Lovelace", "England"); assertThat(Persons.get().stream() .filter(person -> Objects.equals(personToFind.name(), person.name()) && Objects.equals(personToFind.surname(), person.surname()) && ..read more
Visit website

Follow Random Thoughts on Java Programming on FeedSpot

Continue with Google
Continue with Apple
OR