Single table inheritance in Spring Boot and Thymeleaf

302
January 26, 2017, at 06:23 AM

I am using single table inheritance in JPA.

-Car -- E-Car -- Gasoline-Car

In my thymeleaf template, I access a list of the superclass (car) via for-each, in order to create a table with objects of both subclasses.

<tr th:each="car : ${cars}" 
th:class="${not car.isECar()} ? 'electricCar' : 'notECar'">

I now have the problem, that I want to access a property of a subclass, which does not exist in the other one.

<td th:text="'kWh ' + ${car.kwh}" style="vertical-align: center;">1025 kWh</td>

This throws following exception:

org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 6): Property or field '...' cannot be found on object of type ...

Is there any way to render a html-tag, only if a property exists?

READ ALSO
JavaFX LineChart how to handle NaN, null, or POSITIVE_INFINITY?

JavaFX LineChart how to handle NaN, null, or POSITIVE_INFINITY?

I trying to add DoubleNaN value as I do in JFreeChart, but JavaFX cant handle it correctly, so it makes this code

552
Adding an attribute to yii2 active record model that is not in database

Adding an attribute to yii2 active record model that is not in database

I have a mySQL database that has a table videos and two columns, start_time and end_time, which are in the format 2017-01-24 15:38:11

569
Redirecting non-www subfolder domain to www on wordpress multisite

Redirecting non-www subfolder domain to www on wordpress multisite

I currently have a multisite built in wordpressThe domain is set up to be:

240
return statement not return any value in php function

return statement not return any value in php function

Can someone tell me why my return statement is not return any value in data[0] however if i choose to echo it, it shows that there is a value in data[0] but wouldn't work with the return statement

405