Skip to content

Commit

Permalink
BZ-1255404 - Cannot open persistence.xml if transaction-type attribut…
Browse files Browse the repository at this point in the history
…e not present

(cherry picked from commit c88a36a)
  • Loading branch information
wmedvede committed Aug 31, 2015
1 parent 703ee7d commit b656896
Showing 1 changed file with 13 additions and 1 deletion.
Expand Up @@ -62,7 +62,7 @@ private void visitPersistenceUnit( Element element ) {

persistenceUnit.setName( element.getAttribute( PersistenceDescriptorXMLMarshaller.NAME ) );
String transactionType = element.getAttribute( PersistenceDescriptorXMLMarshaller.TRANSACTION_TYPE );
persistenceUnit.setTransactionType( transactionType != null ? TransactionType.valueOf( transactionType ) : null );
persistenceUnit.setTransactionType( parseTransactionType( transactionType ) );

visitDescription( persistenceUnit, element.getElementsByTagName( PersistenceDescriptorXMLMarshaller.DESCRIPTION ) );
visitProvider( persistenceUnit, element.getElementsByTagName( PersistenceDescriptorXMLMarshaller.PROVIDER ) );
Expand Down Expand Up @@ -160,4 +160,16 @@ private String parseSimpleTextElement( NodeList nodes ) {
return result;
}

private TransactionType parseTransactionType( String value ) {
if ( value != null ) {
try {
return TransactionType.valueOf( value.trim() );
} catch ( Exception e ) {
//invalid values will be interpreted as if the transaction type is not set
//this will le the user the chance to set a valid value in the UI
}
}
return null;
}

}

0 comments on commit b656896

Please sign in to comment.