What is the purpose of @NamedArg annotation in javaFX 8?

The @NamedArg annotation allows an FXMLLoader to instantiate a class that does not have a zero-argument constructor. Technical Background: The FXMLLoader creates objects using reflection. Typically, if you use a tag corresponding to a class with a constructor taking no arguments, an object is created from that class by calling Class.newInstance(), which invokes the no-argument … Read more

Selenium @FindBy vs driver.findElement()

Roughly speaking, @FindBy is just an alternate way of finding elements (the “usual way” being driver.findElement() as you said). The big advantage of that annotation is not itself, though. It is better used to support the PageObject pattern. In a few words, the PageObject pattern tells you to create a class for each page of … Read more

JPA Multiple Embedded fields with prefix?

If you would like to use multiple same Embedded class. You have to do @AttributeOverrides for all columns. Try as below; Reference JPA AttributeOverrides @Embeddable public class Address { private String state; @Column(name = “zip_code”) private String zip; } @Entity(name = “Employee”) public class Employee implements Serializable { @Embedded @AttributeOverrides({ @AttributeOverride(name = “state”, column = … Read more

How to map Hibernate entity fields using camelCase to snake_case (underscore) database identifiers

You can achieve this using a custom Hibernate naming strategy. All you need to do is to use the hibernate-types open-source project. Hibernate 5.2 or later You need to add the following Maven dependency: <dependency> <groupId>com.vladmihalcea</groupId> <artifactId>hibernate-types-52</artifactId> <version>${hibernate-types.version}</version> </dependency> And set the following Hibernate configuration property: <property name=”hibernate.physical_naming_strategy” value=”com.vladmihalcea.hibernate.type.util.CamelCaseToSnakeCaseNamingStrategy” /> Hibernate 5.0 and 5.1 You … Read more

Spring Web MVC: Use same request mapping for request parameter and path variable

You can set both mapping url for the same function and setting id as optional. @RequestMapping(method=RequestMethod.GET, value={“/campaigns”,”/campaigns/{id}”}) public String getCampaignDetails(Model model, @RequestParam(value=”id”, required=false) Long id, @PathVariable(“id”) Long id2) { } though it would map as well when id is not sent, but you can control this inside the method. EDIT: The previous solution doesn’t work … Read more

Why should anybody put annotations on the getters or setters when using JPA to map the classes?

Putting annotations on methods forces JPA to access properties via methods. It makes sense when internal state of your object differs from the database schema: @Entity public class Employee { private String firstName; private String lastName; @Column(name = “EMP_NAME”) // Due to legacy database schema public String getName() { return fisrtName + ” ” + … Read more

Mapping enum types with Hibernate Annotations

Do you need something else than the @Enumerated annotation? For example, the following enum: public enum MyEnum { VALUE1, VALUE2; } Could be used and annotated like this: private MyEnum myEnum; @Column(name=”myenum”) @Enumerated(EnumType.ORDINAL) public MyEnum getMyEnum() { return myEnum } You can specify how the enum should be persisted in the database with the EnumType … Read more

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