Example usage for org.hibernate AssertionFailure AssertionFailure

List of usage examples for org.hibernate AssertionFailure AssertionFailure

Introduction

In this page you can find the example usage for org.hibernate AssertionFailure AssertionFailure.

Prototype

public AssertionFailure(String message) 

Source Link

Document

Creates an instance of AssertionFailure using the given message.

Usage

From source file:com.devnexus.ting.core.hibernate.ImprovedPluralizedNamingStrategy.java

License:Apache License

/**
 * Return the property name or propertyTableName
 *//*from  w w w.j a v  a  2 s .c o  m*/
public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName,
        String referencedColumnName) {
    String header = propertyName != null ? StringHelper.unqualify(propertyName) : propertyTableName;
    if (header == null) {
        throw new AssertionFailure("NamingStrategy not properly filled");
    }
    return columnName(header); //+ "_" + referencedColumnName not used for backward compatibility
}

From source file:com.expressui.core.util.UpperCaseAndUnderscoresNamingStrategy.java

License:Open Source License

@Override
public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName,
        String referencedColumnName) {
    String header = propertyName != null ? insertUnderscores(propertyName) : propertyTableName;
    if (header == null)
        throw new AssertionFailure("NamingStrategy not properly filled");
    return columnName(header + "_" + referencedColumnName).toUpperCase();
}

From source file:com.spartasystems.holdmail.EntityPersistenceTest.java

License:Apache License

@Test
public void shouldSaveRecipients() throws Exception {

    MessageEntity entity = buildBasicEntity();

    String email1 = "herp@somedomain.com";
    String email2 = "derp@somedomaincom";

    entity.setRecipients(//from w w  w  . j  a  v  a 2s.co m
            ImmutableSet.of(new MessageRecipientEntity(email1), new MessageRecipientEntity(email2)));

    long savedEntityId = messageRepository.save(entity).getMessageId();
    MessageEntity loaded = messageRepository.findOne(savedEntityId);

    assertThat(loaded.getRecipients()).hasSize(2);
    asList(email1, email2).forEach(expected -> loaded.getRecipients().stream()
            .filter(recip -> expected.equals(recip.getRecipientEmail())).findFirst()
            .orElseThrow(() -> new AssertionFailure("couldn't find email: " + email1)));

}

From source file:org.beangle.commons.orm.hibernate.RailsNamingStrategy.java

License:Open Source License

/** Return the property name or propertyTableName */
public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName,
        String referencedColumnName) {
    String header = null == propertyName ? propertyTableName : unqualify(propertyName);
    if (header == null) {
        throw new AssertionFailure("NamingStrategy not properly filled");
    }//from  w w w.  jav  a  2  s.c om
    if (isManyToOne()) {
        header = addUnderscores(header);
    } else {
        header = addUnderscores(propertyTableName);
    }
    return header + "_" + referencedColumnName;

}

From source file:org.beangle.model.persist.hibernate.support.RailsNamingStrategy.java

License:Open Source License

/**
 * Return the property name or propertyTableName
 *//*from www.j a v a 2  s.  c o  m*/
public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName,
        String referencedColumnName) {
    String header = null == propertyName ? propertyTableName : unqualify(propertyName);
    if (header == null) {
        throw new AssertionFailure("NamingStrategy not properly filled");
    }
    // workground annotation collection foreignKey.
    if (header.endsWith("s")) {
        header = addUnderscores(propertyTableName);
    } else {
        header = addUnderscores(header);
    }
    return header + "_" + referencedColumnName;
}

From source file:org.libreplan.business.common.LibrePlanClassValidator.java

License:Open Source License

public String getPropertyName(XMember member) {
    //Do no try to cache the result in a map, it's actually much slower (2.x time)
    String propertyName;/*  ww w.  j a v  a  2 s. c o  m*/
    if (XProperty.class.isAssignableFrom(member.getClass())) {
        propertyName = member.getName();
    } else if (XMethod.class.isAssignableFrom(member.getClass())) {
        propertyName = member.getName();
        if (propertyName.startsWith("is")) {
            propertyName = Introspector.decapitalize(propertyName.substring(2));
        } else if (propertyName.startsWith("get")) {
            propertyName = Introspector.decapitalize(propertyName.substring(3));
        }
        //do nothing for non getter method, in case someone want to validate a PO Method
    } else {
        throw new AssertionFailure("Unexpected member: " + member.getClass().getName());
    }
    return propertyName;
}

From source file:org.squashtest.tm.infrastructure.hibernate.UppercaseUnderscoreNamingStrategy.java

License:Open Source License

@Override
public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName,
        String referencedColumnName) {
    // Adapted from DefaultNamingStrategy

    String header = propertyName != null ? propertyToColumnName(propertyName) : propertyTableName;
    if (header == null) {
        throw new AssertionFailure("NammingStrategy not properly filled");
    }//from  w w  w.ja v a2 s . c om
    return columnName(header); // + "_" + referencedColumnName not used for backward compatibility
}