it.tidalwave.bluebill.stats.domain.jpa.JpaPingDao Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* blueBill Stats
* Copyright (C) 2011-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************
*
* WWW: http://bluebill.tidalwave.it/mobile/
* SCM: http://java.net/hg/bluebill-server~stats-src
*
**********************************************************************************************************************/
package it.tidalwave.bluebill.stats.domain.jpa;
import javax.annotation.Nonnull;
import javax.persistence.Query;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import it.tidalwave.role.IdFactory;
import it.tidalwave.bluebill.stats.domain.Ping;
import it.tidalwave.bluebill.stats.domain.PingDao;
import it.tidalwave.bluebill.stats.domain.PingFinder;
import it.tidalwave.bluebill.stats.domain.JpaPing;
import org.springframework.transaction.annotation.Transactional;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id: JpaPingDao.java,v cc9c3c80517c 2011/07/15 21:16:27 fabrizio $
*
**********************************************************************************************************************/
@RequiredArgsConstructor @NoArgsConstructor
public class JpaPingDao implements PingDao
{
@Nonnull
private IdFactory idFactory;
@PersistenceContext
private EntityManager em;
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Nonnull
public PingFinder findPings()
{
return new JpaPingFinder(this);
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Override @Transactional
public void insert (final @Nonnull Ping ping)
{
em.persist(new JpaPing(ping, idFactory.createId(JpaPing.class).stringValue()));
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull @Transactional // FIXME: @Transactional doesn't work in a non-public method
/* package */ Query createQuery (final @Nonnull String jpaql)
{
return em.createQuery(jpaql);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy