Java

Why I am not a fan of Hibernate

Rich Domain Model + Lazy-loading cause problems Hiberntate encourages rich domain model over table model, that is,  A.b instead of A.bId You must enable lazy-loading, otherwise there will be performance issues If you are not in a hibernate session, A.b will be invalid ("Partial Materialization" problem) To make user you are in a hibernate session, …

Why I am not a fan of Hibernate Read More »

How to send an email with image files and the the images are shown on page instead of being attachments ?

Your email must satisfy the following rules: 1. it’s a multi-part email 2. it has an "html" as one of its parts (content type must be set) 3. every image must have a header like "Content-ID: <some-id>", and of course, content type must be set 4. the <img> tags in your html must use "cid" …

How to send an email with image files and the the images are shown on page instead of being attachments ? Read More »

bean-validation + spring example

Add bean validation dependency Hibernate provides an implementation of bean-validation. So we will dependent on it. But it has nothing to do with Hiberante ORM. org.hibernate hibernate-validator 5.1.3.Final Create a validator class as a spring bean @Component public class MyBeanValidator { @Resource private Validator validator; public <T> List<String> validateBean(T bean) { List<string> errors = new …

bean-validation + spring example Read More »

JavaFX: how to let one FXML include another

How to let one fxml include another, e.g. let every scene has a "header" ? Note you have to set "fx:id=…" There must be a controller for the included fxml file. Let’s call it HeaderController public class HeaderController { @FXML private Text errorText; … Include the HeaderController in your controller public class LoginController { //the …

JavaFX: how to let one FXML include another Read More »