java - The entity has no primary key attribute defined -
i'm new jpa , have been struggling error time now. eclipse "saying" entity not have primary key defined, read bunch of tutorials , way it.
example: https://en.wikibooks.org/wiki/java_persistence/identity_and_sequencing#example_embedded_id_xml
<?xml version="1.0" encoding="utf-8" ?> <entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"> <entity name="befriendableuser" class="com.projects.socialconnections.befriendableuser.befriendableuser" access="field"> <embedded-id class="com.projects.socialconnections.befriendableuser.befriendableuserid"/> </entity> <embeddable name="befriendableuserid" class="com.projects.socialconnections.befriendableuser.befriendableuserid" access="field"> <attributes> <basic name="numid"> <column name="befriendable_user_id" /> </basic> </attributes> </embeddable> </entity-mappings>
your xml wrong, link (now corrected - refer jpa spec facts not wikis prone error).
embedded-id
should under attributes
element, , attribute name in embedded-id
name
, not class
. see xsd schema @ http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd
Comments
Post a Comment