This is more a conceptual question i.e. 

I am using Spring Application Context to instantiate and manage my objects. i have an application that consists of the following layers. 

Model(DAO), Repository, Service 

Now in the Repository and the Service layers all Classes implement there corresponding interfaces and i am able to call a method of those layer simply by calling the method of the corresponding interface for example:

```
@Autowired
public IUserRepository iUserRepository;
iUserRepository.doSomething();

```

In my Model(DAO) layer i have classes that are annotated with 

```
@Repository
@Entity
@Table(name = "USERS")
public class Users {
...
}

```

The problem that i am facing is the flowing. In my Service layer when i try to instantiate an object from the Model (DAO) layer i.e. :

```
Users userTest =  (Users)context.getBean("users");

```

i get the object of type "Users", however that is not exactly "Users" object but a proxy object instantiated trough CGLIB based proxy.
That proxy object has additional Attributes. See attached picture from the debugging.
![enter image description here](https://i.stack.imgur.com/T3vaC.png)

When i try to pass it further to my repository layer i get the error listed below

If i instantiate an object of the same class with the operator "new", then everything works well i.e i am able to save that object in the database. 

```
user = new Users();

iUserRepository.createUser(user);

```

Till now i have learned that i shell NOT use the "new" operator in Spring i.e. Spring Application context(container) shell manage all of the objects however how to deal with this scenario.

My DAO Users object does have a default constructor but does not implement any interfaces thus JdkDynamicAopProxy is not being used, instead CGLIB based proxy is created. But that proxy object is not accepted as a User object of my repository later i.e. i get that "org.hibernate.MappingException: Unknown entity: " error message.

The question is what is the "right" construct/constellation i.e. is it ok to use the new operator or am i making some typical mistake that i am not aware of it yet. 

```
2014-10-12 11:13:53.707 ERROR 8388 --- [           main] o.s.R.account.UserRepositoryImpl         : Exception

org.hibernate.MappingException: Unknown entity: org.syncServer.Model.acount.Users$$EnhancerBySpringCGLIB$$54139ff4
    at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1095)
    at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1439)
    at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:116)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
    at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
    at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
    at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:711)
    at org.hibernate.internal.SessionImpl.save(SessionImpl.java:703)
    at org.hibernate.internal.SessionImpl.save(SessionImpl.java:698)
    at org.syncServer.Repository.account.UserRepositoryImpl.create(UserRepositoryImpl.java:186)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    at com.sun.proxy.$Proxy76.create(Unknown Source)
    at org.syncServer.Service.account.UserServiceImpl.create(UserServiceImpl.java:266)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    at com.sun.proxy.$Proxy81.create(Unknown Source)
    at org.syncServer.core.Tests.createUser(Tests.java:44)
    at org.syncServer.core.Application.main(Application.java:95)

```