How to configure schema name for mapped entity / table in JPA / hibernate
by Tang Jianyu
Hi,
I have a question posted to stackoverflow but haven't get answer, so
want to check if someone here can help me
http://stackoverflow.com/questions/12192453/how-to-configure-schema-name-...
I have an application which need to access 2 schemas at runtime, and
the schema names need to be configured when deploy, because the name
are different for each deployment (for assembly testing, integration
testing, performance testing...)
I know JPA / hibernate can specify schema on @Table annotation, but I
need to make the schema configurable, is there anyway to add a post
processor / event listener so I can modify the hibernate meta info,
and change the table schema with my configuration?
Currently I'm looking into rewrite my own HibernateJpaVendorAdapter /
HibernatePersistence / MetaProvider, but definitely this is not a good
idea.
Thanks
Jeffrey
12 years, 4 months
Problem with MappedSuperclass
by Christian Beikov
Hello!
I have a strange problem, which I don't have in my company related to
the usage of mapped superclasses.
I have a base entity which encapsulates the id like this:
@MappedSuperclass
public abstract class SimpleEntity<T extends Serializable> implements
Serializable {
private static final long serialVersionUID = 1L;
private T id;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"idGenerator")
@Column(name = "id", nullable = false, insertable = false,
updatable = false)
public T getId() {
return id;
}
public void setId(T id) {
this.id = id;
}
}
A concrete class example looks like:
@Entity
@SequenceGenerator(name = "idGenerator", sequenceName = "my_entity_seq",
initialValue = 1, allocationSize = 1)
public class MyEntity extends SimpleEntity<Integer> {
private static final long serialVersionUID = 1L;
private String name;
public String getName() {
return name;
}
public void setName(T name) {
this.name = name;
}
}
But when I try to start the application I get the following error:
Caused by: org.hibernate.AnnotationException: Unknown Id.generator:
idGenerator
at
org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:507)
at
org.hibernate.cfg.AnnotationBinder.processId(AnnotationBinder.java:2126)
at
org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2038)
at
org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:765)
at
org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:684)
at
org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3406)
at
org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3360)
at
org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1334)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724)
at
org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
... 9 more
This is just a simple example, anyway I have a lot of mapped super
classes in my app.
Any ideas what the cause of the error might be? The message is not
really helpful, also it doesn't point out where the error occurred.
Regards,
Christian
12 years, 4 months
Hibernate search master build issues
by Nicolas Helleringer
Hi all,
Since ~10 days, I do have build issue with master branch :
Failed tests:
searchNewMemberBeforeSynchronizationOnSlave1(org.hibernate.search.test.integration.jms.SearchBeforeIndex
SynchronizationJmsMasterSlaveIT): Found user created by Slave 1: [[1,
Davide D'Alto, dd(a)slave1.fake.email]] expected:<0>
but was:<1>
searchNewMemberBeforeSynchronizationOnSlave2(org.hibernate.search.test.integration.jms.SearchBeforeIndexSynchronizatio
nJmsMasterSlaveIT): Found user created by Slave 1: [[1, Davide D'Alto,
dd(a)slave1.fake.email]] expected:<0> but was:<1>
Any changes on this ?
Niko
12 years, 4 months
[OGM] query logging
by Guillaume SCHEIBEL
Hi guys,
What do you think about implementing a configuration property like
"hibernate.show_sql" ?
It's a really useful feature in ORM.
What do you think ?
Guillaume
12 years, 4 months
Hibernate Envers question
by Christian Beikov
Hello!
I wondered how envers works/could work in a JPA portable way. Are you
using somehow a entity listener approach or so? Does the the code needed
for envers really depend on the hibernate core stuff or does hibernate
just offer a more relaxed contract in respect to entity listeners?
I was just wondering why nobody proposed the auditing stuff to be
included in the jpa spec since there were already many requests for
auditing for other jpa impls. IMO it's a fairly common issue to address
auditing and therefore worth to, not necessarily be standardized but, at
least be provider independent.
I don't have a problem with hibernate at all, I will go on using it
since it's just great, but the question just came up in my head and I
wanted to know if you maybe already discussed something like that with
the jpa team?
Regards,
Christian
12 years, 4 months