What’s the difference between session.persist() and session.save() in Hibernate?

From this forum post persist() is well defined. It makes a transient instance persistent. However, it doesn’t guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time. The spec doesn’t say that, which is the problem I have with persist(). persist() also guarantees that it will not execute an … Read more

java.io.IOException: Broken pipe

The most common reason I’ve had for a “broken pipe” is that one machine (of a pair communicating via socket) has shut down its end of the socket before communication was complete. About half of those were because the program communicating on that socket had terminated. If the program sending bytes sends them out and … Read more

Making a Java Makefile

For a simple project without many files or dependencies, I simply use scripts. To build: To run: Replace . with whatever path(s) you need for your source. The * will use any jar on the default path or use a different path like lib/*.

PrintWriter append method not appending

The fact that PrintWriter‘s method is called append() doesn’t mean that it changes mode of the file being opened. You need to open file in append mode as well: Also note that file will be written in system default encoding. It’s not always desired and may cause interoperability problems, you may want to specify file encoding explicitly.

org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set

First remove all of your configuration Spring Boot will start it for you. Make sure you have an application.properties in your classpath and add the following properties. If you really need access to a SessionFactory and that is basically for the same datasource, then you can do the following (which is also documented here although for XML, not JavaConfig). That way … Read more

How to set or change the default Java (JDK) version on macOS?

First run /usr/libexec/java_home -V which will output something like the following: Pick the version you want to be the default (1.6.0_65-b14-462 for arguments sake) then: or you can specify just the major version, like: Now when you run java -version you will see: Add the export JAVA_HOME… line to your shell’s init file. For Bash (as stated by antonyh): For Fish (as stated … Read more

Simple Java 2D graphics: draw a rectangle?

To draw a rectangle in Swing you should: First of all, never draw directly in the JFrame or other top-level window. Instead draw in a JPanel, JComponent or other class that eventually extends from JComponent. You should override the paintComponent(Graphics g) method. You should be sure to call the super method You should draw your rectangle with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)