Repository navigation
Description
Den Orlov opened SPR-8589 and commented
I configured
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="packagesToScan" value="ru.massmo"/>
<property name="annotatedClasses" value="ru.massmo.tele2.invoiceapi.model.ClientId, ru.massmo.tele2.invoiceapi.model.SubscriberId"/>
<property name="dataSource" ref="incidentsDataSource"/>
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy"/>
</property>
<property name="hibernateProperties">
<value>
hibernate.hbm2ddl.auto=create
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.connection.charSet=UTF-8
hibernate.validator.apply_to_ddl=false hibernate.validator.autoregister_listeners=false hibernate.cache.use_query_cache=true hibernate.cache.provider_class=net.sf.ehcache.hibernate.SingletonEhCacheProvider
</value>
</property>
</bean>
put
@TypeDefs(
{
@TypeDef(
name = "oracleNullSafeString",
defaultForType = String.class,
typeClass = OracleNullSafeString.class
)
}
)package ru.massmo.tele2.incidents.model;
import org.hibernate.annotations.TypeDef;import org.hibernate.annotations.TypeDefs;import ru.massmo.hibernate.OracleNullSafeString;
into \src\ru\massmo\tele2\incidents\model\package-info.java
But according to logs Hibernate does not found my OracleNullSafeString UserType.
When I put @TypeDef at Entity file (into \src\ru\massmo\tele2\incidents\model\Subject.java):
@Entity
@Access(value = AccessType.FIELD)
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@TypeDefs(
{
@TypeDef(
name = "oracleNullSafeString",
defaultForType = String.class,
typeClass = OracleNullSafeString.class
)
}
)
hibernate found my OracleNullSafeString type correctly.
Affects: 3.0.5
Issue Links:
- In AnnotationSessionFactoryBean, be able to specify annotatedPackages and packagesToScan in one property [SPR-10288] #14922 In AnnotationSessionFactoryBean, be able to specify annotatedPackages and packagesToScan in one property
- Propagate LCEMFB.packagesToScan to native PersistenceProvider to pick up annotated packages [SPR-10910] #15538 Propagate LCEMFB.packagesToScan to native PersistenceProvider to pick up annotated packages
10 votes, 15 watchers
Activity
spring-projects-issues commentedon Nov 20, 2013
Peter Cooper Jr. commented
I believe this is also true when using
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean, because theDefaultPersistenceUnitManager.entityTypeFiltersexclude the package-info from being scanned.spring-projects-issues commentedon Jan 8, 2014
Juergen Hoeller commented
Resolved through #14922, as of Spring Framework 3.2.2.
Juergen
spring-projects-issues commentedon Jan 17, 2014
Peter Cooper Jr. commented
I'm using Spring 4.0.0, and I don't think this is resolved, at least not with
LocalContainerEntityManagerFactoryBean. I need to put my@TypeDefon a class marked with@Entityor@MappedSuperclass, as it doesn't scan the package-info for them.spring-projects-issues commentedon Jan 17, 2014
Matt Bertolini commented
Based on the description of #14922, it looks like the change was only made for the Hibernate specific
AnnotationSessionFactoryBeanand forgot to the include the various JPAEntityManagerFactoryBeanclasses. Perhaps a new ticket should be opened for the JPA classes?spring-projects-issues commentedon Jan 17, 2014
Juergen Hoeller commented
Peter, Matt,
We already have #15538 for JPA support there, making our HibernateJpaVendorAdapter pick up annotated packages. However, due to the rather rigid JPA SPI contract, there is no standard way to discover annotated packages and pass them through to the persistence provider. There are ways to work around this but they are rather involved, so we have scheduled them for 4.1 at this point. Note that Spring Framework 4.1 is planned for GA this August, so it's not too far out.
Juergen
spring-projects-issues commentedon Jan 23, 2014
Guillaume Deimat commented
I have some JAXB annotations in package-info.java (
@XmlAccessorFactoryand@XmlAccessType), and they seems to be ignored too. I don't know if my problem can be related to this issue?spring-projects-issues commentedon Aug 11, 2017
Pramod Bhargava commented
This Issue is still not fixed in spring 4.3.5
spring-projects-issues commentedon Aug 11, 2017
Pramod Bhargava commented
I am using spring-boot 1.4.3
which uses spring 4.3.5 Still not able to get typedefs from package-info.java
My configurations
package-info.java
@TypeDefs({
@TypeDef(name="encryptedString",
typeClass=EncryptedStringType.class,
parameters={
@Parameter(name="encryptorRegisteredName",value="rcmHibernateStringEncryptor")
}
)
})
package com.bcv.kagami.modules.model;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.hibernate.annotations.Parameter;
import org.jasypt.hibernate4.type.EncryptedStringType;
Getting no class found encryptedString
spring-projects-issues commentedon Aug 11, 2017
Juergen Hoeller commented
Please don't reopen such an old issue which has been addressed for the native Hibernate support outside of JPA (its original purpose). Making this work with JPA has been covered in #15538 but please don't reopen that one either; instead, we'd prefer a new issue for your specific scenario.