From 0fc9dbc4bf96b56b5a314486e52d14168da4167d Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 24 Jan 2018 12:41:17 +0100 Subject: [PATCH] DATAJPA-1252 - Fix line endings to LF. --- .../data/jpa/domain/sample/MailMessage.java | 118 +++++------ .../data/jpa/domain/sample/MailSender.java | 196 +++++++++--------- .../cdi/EntityManagerFactoryProducer.java | 78 +++---- .../data/jpa/repository/cdi/Person.java | 94 ++++----- .../data/jpa/repository/cdi/PersonDB.java | 60 +++--- .../jpa/repository/cdi/PersonRepository.java | 56 ++--- .../cdi/QualifiedEntityManagerProducer.java | 96 ++++----- .../cdi/QualifiedPersonRepository.java | 46 ++-- .../repository/cdi/RepositoryConsumer.java | 98 ++++----- .../jpa/repository/cdi/Transactional.java | 60 +++--- .../cdi/TransactionalInterceptor.java | 138 ++++++------ .../cdi/UnqualifiedEntityManagerProducer.java | 66 +++--- .../cdi/UnqualifiedPersonRepository.java | 44 ++-- src/test/resources/hibernate.xml | 8 +- 14 files changed, 579 insertions(+), 579 deletions(-) diff --git a/src/test/java/org/springframework/data/jpa/domain/sample/MailMessage.java b/src/test/java/org/springframework/data/jpa/domain/sample/MailMessage.java index 98e5e2fa8..1278084fc 100755 --- a/src/test/java/org/springframework/data/jpa/domain/sample/MailMessage.java +++ b/src/test/java/org/springframework/data/jpa/domain/sample/MailMessage.java @@ -1,59 +1,59 @@ -/* - * Copyright 2013-2018 the original author or authors. - * - * 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.springframework.data.jpa.domain.sample; - -import javax.persistence.CascadeType; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.OneToOne; - -/** - * @author Thomas Darimont - */ -@Entity -public class MailMessage { - - @Id @GeneratedValue private Long id; - - @OneToOne(cascade = CascadeType.ALL) private MailSender mailSender; - - private String content; - - public MailSender getMailSender() { - return mailSender; - } - - public void setMailSender(MailSender sender) { - this.mailSender = sender; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } -} +/* + * Copyright 2013-2018 the original author or authors. + * + * 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.springframework.data.jpa.domain.sample; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToOne; + +/** + * @author Thomas Darimont + */ +@Entity +public class MailMessage { + + @Id @GeneratedValue private Long id; + + @OneToOne(cascade = CascadeType.ALL) private MailSender mailSender; + + private String content; + + public MailSender getMailSender() { + return mailSender; + } + + public void setMailSender(MailSender sender) { + this.mailSender = sender; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} diff --git a/src/test/java/org/springframework/data/jpa/domain/sample/MailSender.java b/src/test/java/org/springframework/data/jpa/domain/sample/MailSender.java index 9b6e445e3..1bfef2e53 100644 --- a/src/test/java/org/springframework/data/jpa/domain/sample/MailSender.java +++ b/src/test/java/org/springframework/data/jpa/domain/sample/MailSender.java @@ -1,98 +1,98 @@ -/* - * Copyright 2013-2018 the original author or authors. - * - * 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.springframework.data.jpa.domain.sample; - -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.ManyToOne; - -/** - * @author Thomas Darimont - */ -@Entity -public class MailSender { - - @Id @GeneratedValue private Long id; - - private String name; - - @ManyToOne(fetch = FetchType.LAZY) private MailUser mailUser; - - public MailSender() {} - - public MailSender(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public MailUser getMailUser() { - return mailUser; - } - - public void setMailUser(MailUser mailUser) { - this.mailUser = mailUser; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - MailSender other = (MailSender) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } -} +/* + * Copyright 2013-2018 the original author or authors. + * + * 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.springframework.data.jpa.domain.sample; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +/** + * @author Thomas Darimont + */ +@Entity +public class MailSender { + + @Id @GeneratedValue private Long id; + + private String name; + + @ManyToOne(fetch = FetchType.LAZY) private MailUser mailUser; + + public MailSender() {} + + public MailSender(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public MailUser getMailUser() { + return mailUser; + } + + public void setMailUser(MailUser mailUser) { + this.mailUser = mailUser; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MailSender other = (MailSender) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/EntityManagerFactoryProducer.java b/src/test/java/org/springframework/data/jpa/repository/cdi/EntityManagerFactoryProducer.java index ba0e1360c..0db82b39c 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/EntityManagerFactoryProducer.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/EntityManagerFactoryProducer.java @@ -1,39 +1,39 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Disposes; -import javax.enterprise.inject.Produces; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; - -import org.hibernate.Version; - -class EntityManagerFactoryProducer { - - @Produces - @ApplicationScoped - public EntityManagerFactory createEntityManagerFactory() { - - String hibernateVersion = Version.getVersionString(); - return Persistence.createEntityManagerFactory(hibernateVersion.startsWith("5.2") ? "cdi-52" : "cdi"); - } - - public void close(@Disposes EntityManagerFactory entityManagerFactory) { - entityManagerFactory.close(); - } -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Disposes; +import javax.enterprise.inject.Produces; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; + +import org.hibernate.Version; + +class EntityManagerFactoryProducer { + + @Produces + @ApplicationScoped + public EntityManagerFactory createEntityManagerFactory() { + + String hibernateVersion = Version.getVersionString(); + return Persistence.createEntityManagerFactory(hibernateVersion.startsWith("5.2") ? "cdi-52" : "cdi"); + } + + public void close(@Disposes EntityManagerFactory entityManagerFactory) { + entityManagerFactory.close(); + } +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/Person.java b/src/test/java/org/springframework/data/jpa/repository/cdi/Person.java index dd1469431..6b10439db 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/Person.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/Person.java @@ -1,47 +1,47 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -class Person { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String name; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/PersonDB.java b/src/test/java/org/springframework/data/jpa/repository/cdi/PersonDB.java index 4d5a14907..aeab627fe 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/PersonDB.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/PersonDB.java @@ -1,30 +1,30 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -@Qualifier -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER }) -@interface PersonDB { - -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER }) +@interface PersonDB { + +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/PersonRepository.java b/src/test/java/org/springframework/data/jpa/repository/cdi/PersonRepository.java index 1ad1190ba..188f3ba79 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/PersonRepository.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/PersonRepository.java @@ -1,28 +1,28 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import java.util.List; - -import org.springframework.data.repository.cdi.Eager; - -@Eager -public interface PersonRepository { - - List findAll(); - - void save(Person person); -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import java.util.List; + +import org.springframework.data.repository.cdi.Eager; + +@Eager +public interface PersonRepository { + + List findAll(); + + void save(Person person); +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedEntityManagerProducer.java b/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedEntityManagerProducer.java index 8576a0603..81c1f84e6 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedEntityManagerProducer.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedEntityManagerProducer.java @@ -1,48 +1,48 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import javax.enterprise.inject.Disposes; -import javax.enterprise.inject.Produces; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; - -/** - * @author Oliver Gierke - * @author Mark Paluch - */ -class QualifiedEntityManagerProducer { - - @Produces - @PersonDB - public EntityManager createPersonDBEntityManager(EntityManagerFactory entityManagerFactory) { - return entityManagerFactory.createEntityManager(); - } - - public void closePersonDB(@Disposes @PersonDB EntityManager entityManager) { - entityManager.close(); - } - - @Produces - @UserDB - public EntityManager createUserDBEntityManager(EntityManagerFactory entityManagerFactory) { - return entityManagerFactory.createEntityManager(); - } - - public void closeUserDB(@Disposes @UserDB EntityManager entityManager) { - entityManager.close(); - } -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import javax.enterprise.inject.Disposes; +import javax.enterprise.inject.Produces; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + +/** + * @author Oliver Gierke + * @author Mark Paluch + */ +class QualifiedEntityManagerProducer { + + @Produces + @PersonDB + public EntityManager createPersonDBEntityManager(EntityManagerFactory entityManagerFactory) { + return entityManagerFactory.createEntityManager(); + } + + public void closePersonDB(@Disposes @PersonDB EntityManager entityManager) { + entityManager.close(); + } + + @Produces + @UserDB + public EntityManager createUserDBEntityManager(EntityManagerFactory entityManagerFactory) { + return entityManagerFactory.createEntityManager(); + } + + public void closeUserDB(@Disposes @UserDB EntityManager entityManager) { + entityManager.close(); + } +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedPersonRepository.java b/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedPersonRepository.java index 9f0dada28..283b7f449 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedPersonRepository.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedPersonRepository.java @@ -1,23 +1,23 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import org.springframework.data.repository.Repository; - -@PersonDB -public interface QualifiedPersonRepository extends PersonRepository, Repository { - -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import org.springframework.data.repository.Repository; + +@PersonDB +public interface QualifiedPersonRepository extends PersonRepository, Repository { + +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/RepositoryConsumer.java b/src/test/java/org/springframework/data/jpa/repository/cdi/RepositoryConsumer.java index 73572cd0d..63290396a 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/RepositoryConsumer.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/RepositoryConsumer.java @@ -1,49 +1,49 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import javax.inject.Inject; - -/** - * @author Oliver Gierke - * @author Mark Paluch - */ -@Transactional -class RepositoryConsumer { - - @Inject PersonRepository unqualifiedRepo; - @Inject @PersonDB PersonRepository qualifiedRepo; - @Inject SamplePersonRepository samplePersonRepository; - @Inject @UserDB QualifiedCustomizedUserRepository qualifiedCustomizedUserRepository; - - public void findAll() { - unqualifiedRepo.findAll(); - qualifiedRepo.findAll(); - } - - public void save(Person person) { - unqualifiedRepo.save(person); - qualifiedRepo.save(person); - } - - public int returnOne() { - return samplePersonRepository.returnOne(); - } - - public void doSomethonOnUserDB() { - qualifiedCustomizedUserRepository.doSomething(); - } -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import javax.inject.Inject; + +/** + * @author Oliver Gierke + * @author Mark Paluch + */ +@Transactional +class RepositoryConsumer { + + @Inject PersonRepository unqualifiedRepo; + @Inject @PersonDB PersonRepository qualifiedRepo; + @Inject SamplePersonRepository samplePersonRepository; + @Inject @UserDB QualifiedCustomizedUserRepository qualifiedCustomizedUserRepository; + + public void findAll() { + unqualifiedRepo.findAll(); + qualifiedRepo.findAll(); + } + + public void save(Person person) { + unqualifiedRepo.save(person); + qualifiedRepo.save(person); + } + + public int returnOne() { + return samplePersonRepository.returnOne(); + } + + public void doSomethonOnUserDB() { + qualifiedCustomizedUserRepository.doSomething(); + } +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/Transactional.java b/src/test/java/org/springframework/data/jpa/repository/cdi/Transactional.java index 300637693..710f0f224 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/Transactional.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/Transactional.java @@ -1,30 +1,30 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.interceptor.InterceptorBinding; - -@InterceptorBinding -@Target({ ElementType.METHOD, ElementType.TYPE }) -@Retention(RetentionPolicy.RUNTIME) -@interface Transactional { - -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.interceptor.InterceptorBinding; + +@InterceptorBinding +@Target({ ElementType.METHOD, ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@interface Transactional { + +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/TransactionalInterceptor.java b/src/test/java/org/springframework/data/jpa/repository/cdi/TransactionalInterceptor.java index c32abfef4..bfd2a1a9e 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/TransactionalInterceptor.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/TransactionalInterceptor.java @@ -1,69 +1,69 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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. - */ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import javax.enterprise.inject.Any; -import javax.inject.Inject; -import javax.interceptor.AroundInvoke; -import javax.interceptor.Interceptor; -import javax.interceptor.InvocationContext; -import javax.persistence.EntityManager; -import javax.persistence.EntityTransaction; - -@Transactional -@Interceptor -class TransactionalInterceptor { - - @Inject - @Any - private EntityManager entityManager; - - @AroundInvoke - public Object runInTransaction(InvocationContext ctx) throws Exception { - EntityTransaction entityTransaction = this.entityManager.getTransaction(); - boolean isNew = !entityTransaction.isActive(); - try { - if (isNew) { - entityTransaction.begin(); - } - Object result = ctx.proceed(); - if (isNew) { - entityTransaction.commit(); - } - return result; - } catch (RuntimeException r) { - if (isNew) { - entityTransaction.rollback(); - } - throw r; - } - } -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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. + */ +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import javax.enterprise.inject.Any; +import javax.inject.Inject; +import javax.interceptor.AroundInvoke; +import javax.interceptor.Interceptor; +import javax.interceptor.InvocationContext; +import javax.persistence.EntityManager; +import javax.persistence.EntityTransaction; + +@Transactional +@Interceptor +class TransactionalInterceptor { + + @Inject + @Any + private EntityManager entityManager; + + @AroundInvoke + public Object runInTransaction(InvocationContext ctx) throws Exception { + EntityTransaction entityTransaction = this.entityManager.getTransaction(); + boolean isNew = !entityTransaction.isActive(); + try { + if (isNew) { + entityTransaction.begin(); + } + Object result = ctx.proceed(); + if (isNew) { + entityTransaction.commit(); + } + return result; + } catch (RuntimeException r) { + if (isNew) { + entityTransaction.rollback(); + } + throw r; + } + } +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/UnqualifiedEntityManagerProducer.java b/src/test/java/org/springframework/data/jpa/repository/cdi/UnqualifiedEntityManagerProducer.java index 4d71846b5..ccfff9fad 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/UnqualifiedEntityManagerProducer.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/UnqualifiedEntityManagerProducer.java @@ -1,33 +1,33 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import javax.enterprise.inject.Disposes; -import javax.enterprise.inject.Produces; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; - -class UnqualifiedEntityManagerProducer { - - @Produces - public EntityManager createEntityManager(EntityManagerFactory entityManagerFactory) { - return entityManagerFactory.createEntityManager(); - } - - public void close(@Disposes EntityManager entityManager) { - entityManager.close(); - } -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import javax.enterprise.inject.Disposes; +import javax.enterprise.inject.Produces; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + +class UnqualifiedEntityManagerProducer { + + @Produces + public EntityManager createEntityManager(EntityManagerFactory entityManagerFactory) { + return entityManagerFactory.createEntityManager(); + } + + public void close(@Disposes EntityManager entityManager) { + entityManager.close(); + } +} diff --git a/src/test/java/org/springframework/data/jpa/repository/cdi/UnqualifiedPersonRepository.java b/src/test/java/org/springframework/data/jpa/repository/cdi/UnqualifiedPersonRepository.java index a54bc335e..5b2221e0d 100644 --- a/src/test/java/org/springframework/data/jpa/repository/cdi/UnqualifiedPersonRepository.java +++ b/src/test/java/org/springframework/data/jpa/repository/cdi/UnqualifiedPersonRepository.java @@ -1,22 +1,22 @@ -/* - * Copyright 2011-2018 the original author or authors. - * - * 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.springframework.data.jpa.repository.cdi; - -import org.springframework.data.repository.Repository; - -public interface UnqualifiedPersonRepository extends PersonRepository, Repository { - -} +/* + * Copyright 2011-2018 the original author or authors. + * + * 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.springframework.data.jpa.repository.cdi; + +import org.springframework.data.repository.Repository; + +public interface UnqualifiedPersonRepository extends PersonRepository, Repository { + +} diff --git a/src/test/resources/hibernate.xml b/src/test/resources/hibernate.xml index 27d04d5b4..8b1cbf337 100644 --- a/src/test/resources/hibernate.xml +++ b/src/test/resources/hibernate.xml @@ -4,9 +4,9 @@ xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> - + - + - - \ No newline at end of file + +