Asked  7 Months ago    Answers:  5   Viewed   227 times

I have my persistence.xml with the same name using TopLink under the META-INF directory. Then, I have my code calling it with:

EntityManagerFactory emfdb = Persistence.createEntityManagerFactory("agisdb");

Yet, I got the following error message:

2009-07-21 09:22:41,018 [main] ERROR - No Persistence provider for EntityManager named agisdb
javax.persistence.PersistenceException: No Persistence provider for EntityManager named agisdb
    at javax.persistence.Persistence.createEntityManagerFactory(
    at javax.persistence.Persistence.createEntityManagerFactory(

Here is the persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="" version="1.0">
    <persistence-unit name="agisdb">
            <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/agisdb"/>
            <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
            <property name="toplink.jdbc.user" value="root"/>
            <property name="toplink.jdbc.password" value="password"/>

It should have been in the classpath. Yet, I got the above error.



After <persistence-unit name="agisdb">, define the persistence provider name:

Tuesday, June 1, 2021
answered 7 Months ago

As per the JPA spec:

The persistent fields or properties of an entity maybe of the following types: Java primitive types; java.lang.String; other Java serializable types (including wrappers of the primitive types, java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.util.Calendar[7], java.sql.Date, java.sql.Time, java.sql.Timestamp, user-defined serializable types, byte[], Byte[], char[], andCharacter[]); enums; entity types and/or collections of entity types; and embeddable classes (see section 2.1.5).

Plus the support for collections. But no primitive support of URL. They would however be supported as Serializable, which I guess would result in a LOB as you mentioned.

But you should be able to easily circumvent that: you can have the URL as a String in a field and a getter/setter that convert from String to URL though. Then you map the field with the annotation.

Or the opposite: the java.lang.URL in a field, and getter/setter to convert from URL to String, then you map the getter/setter with the annotation. I think it works as well.

Tuesday, August 3, 2021
answered 4 Months ago

Maybe you miss the Provider class or one of its dependencies in your pom.xml dependencies?

The link you give to the hibernate docs says that you should also add

<project ...>

to your pom.xml

Monday, August 9, 2021
answered 4 Months ago

I think nullable is used if you generate the schema, using the implementation of the entitymanager. I don't know whether it is / has to be validated while persisting an entity as well.

Maybe it helps if you use the @NotNull annotation, but this is NOT plain JPA. It's defined in the JSR-303

There is a topic on Stackoverflow too that covers your question: Stackoverflow - Confusion notnull vs columnnullable false

EDIT: In the JPA 2.1 Specification, there is this section: Column
The following elements of the Column annotation are used in schema generation:
columnDefinition table
length (string-valued columns only) precision (exact numeric (decimal/numeric) columns only) scale (exact numeric (decimal/numeric) columns only) See section 11.1.9 for the rules that apply to these elements and column creation. The AttributeOverride annotation may be used to override column mappings.

As there is no other hint given, I assume the following: If a JPA-conform EntityManager CREATES the schema, it HAS to apply the nullable constraint on the specific column by using an aequivalent DB related constraint (e.g. notnull) When you persist an entity, it is NOT checked by the Entitymanager BUT by the underlying databse. So if the DB raises an error, the EntityManager propagates this error up to the caller.

If you create the table yourself without using the DB nullable constraint, then the entitymanager tries to persist the entity and gets NO error --> persist is okay althouh there are some null values that shouldn't be there.

Monday, August 23, 2021
Paulo Freitas
answered 4 Months ago

I think the class org.hibernate.ejb.Hibernat ePersistence is missing from your classpath. Add it to your pom.xml:


Replace 3.6.10.Final with the appropriate version of Hibernate.

Wednesday, November 3, 2021
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :