views:

122

answers:

1

I have a hibernate.cfg.xml with the JDBC Url configured thus:

<property name="hibernate.connection.url">jdbc:mysql://${server.hostname}:3306/dsm?zeroDateTimeBehavior=convertToNull&amp;jdbcCompliantTruncation=true&amp;autoReconnect=true</property>

Those & are required (instead of just &) in order to avoid the exception: The reference to entity "jdbcCompliantTruncation" must end with the ';' delimiter.

In order to be able to select a different target databases via Maven, I would like to change this to:

<property name="hibernate.connection.url">${jdbc.url}</property>

in which ${jdbc.url} is a property defined in Maven. However the problem is that Maven seems to convert all the & to &, which then causes Hibernate to throw the above exception.

Anyone have a workaround for this?

+3  A: 

Did you try to declare it inside a CDATA section?

<properties>
  <jdbc.url><![CDATA[jdbc:mysql://${server.hostname}:3306/dsm?zeroDateTimeBehavior=convertToNull&amp;jdbcCompliantTruncation=true&amp;autoReconnect=true]]></jdbc.url>
</properties>
Pascal Thivent
No, but that did the trick. Thanks!
JellyHead
@JellyHead You're welcome. And feel free to accept this answer then (the green tick below the votes on the left).
Pascal Thivent