001package com.avaje.ebean.bean; 002 003import javax.persistence.Entity; 004 005/** 006 * Utility to find the root bean type. 007 */ 008public class PersistenceContextUtil { 009 010 /** 011 * Find and return the root bean type for the given class. 012 */ 013 public static Class<?> root(Class<?> beanType) { 014 Class<?> parent = beanType.getSuperclass(); 015 while (parent != null && parent.isAnnotationPresent(Entity.class)) { 016 beanType = parent; 017 parent = parent.getSuperclass(); 018 } 019 return beanType; 020 } 021}