<commit_before>/*
 *    Copyright 2010 The myBatis Team
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.mybatis.guice;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Singleton;

import org.apache.ibatis.session.TransactionIsolationLevel;
import org.mybatis.guice.transactional.Transactional;

/**
 * 
 *
 * @version $Id$
 */
@Singleton
public class ContactMapperClient {

    @Inject
    private ContactMapper contactMapper;

    public void setContactMapper(ContactMapper contactMapper) {
        this.contactMapper = contactMapper;
    }

    @Transactional(
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "Impossible to insert %s contact"
    )
    public void brokenInsert(final Contact contact) throws CustomException {
        this.contactMapper.brokenAdd(contact);
    }

    @Transactional(
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "Impossible to insert %s contact"
    )
    public void insert(final Contact contact) throws CustomException {
        this.contactMapper.add(contact);
    }

    @Transactional(
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "Impossible to delete contact with ID %s"
    )
    public void delete(final Integer id) throws CustomException {
        this.contactMapper.delete(id);
    }

    @Transactional(
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "An error occurred when selecting contact with ID %s"
    )
    public Contact selectById(final Integer id) throws CustomException {
        return this.contactMapper.getById(id);
    }

    @Transactional(
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "An error occurred when selecting all stored contacts"
    )
    public List<Contact> getAll() throws CustomException {
        return this.contactMapper.selectAll();
    }

    @Transactional(
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "An error occurred when updating contact %s"
    )
    public void update(final Contact contact) throws CustomException {
        this.contactMapper.update(contact);
    }

}<commit_msg>updated tests according to new TransactionManagement enum<commit_after>/*
 *    Copyright 2010 The myBatis Team
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.mybatis.guice;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Singleton;

import org.apache.ibatis.session.TransactionIsolationLevel;
import org.mybatis.guice.transactional.TransactionManagement;
import org.mybatis.guice.transactional.Transactional;

/**
 * 
 *
 * @version $Id$
 */
@Singleton
public class ContactMapperClient {

    @Inject
    private ContactMapper contactMapper;

    public void setContactMapper(ContactMapper contactMapper) {
        this.contactMapper = contactMapper;
    }

    @Transactional(
            transactionManagement = TransactionManagement.Managed,
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "Impossible to insert %s contact"
    )
    public void brokenInsert(final Contact contact) throws CustomException {
        this.contactMapper.brokenAdd(contact);
    }

    @Transactional(
            transactionManagement = TransactionManagement.Managed,
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "Impossible to insert %s contact"
    )
    public void insert(final Contact contact) throws CustomException {
        this.contactMapper.add(contact);
    }

    @Transactional(
            transactionManagement = TransactionManagement.Managed,
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "Impossible to delete contact with ID %s"
    )
    public void delete(final Integer id) throws CustomException {
        this.contactMapper.delete(id);
    }

    @Transactional(
            transactionManagement = TransactionManagement.Managed,
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "An error occurred when selecting contact with ID %s"
    )
    public Contact selectById(final Integer id) throws CustomException {
        return this.contactMapper.getById(id);
    }

    @Transactional(
            transactionManagement = TransactionManagement.Managed,
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "An error occurred when selecting all stored contacts"
    )
    public List<Contact> getAll() throws CustomException {
        return this.contactMapper.selectAll();
    }

    @Transactional(
            transactionManagement = TransactionManagement.Managed,
            isolationLevel = TransactionIsolationLevel.SERIALIZABLE,
            rethrowExceptionsAs = CustomException.class,
            exceptionMessage = "An error occurred when updating contact %s"
    )
    public void update(final Contact contact) throws CustomException {
        this.contactMapper.update(contact);
    }

}
{'fraction_non_alphanumeric': 0.06725230414746544, 'fraction_numerical': 0.002304147465437788, 'mean_word_length': 3.054290718038529, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6813002', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1681, 'n_words': 494}