Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » problems using metamodel generator in Eclipse
problems using metamodel generator in Eclipse [message #646732] Thu, 30 December 2010 16:09 Go to next message
Martin Geisse is currently offline Martin GeisseFriend
Messages: 24
Registered: July 2009
Junior Member
Hello,

I am trying to get the EclipseLink metamodel generator working from within Eclipse. To do this, I have enabled annotation processing in the Java compiler options and added the following JARs:

- eclipselink-jpa-modelgen_2.1.2.v20101206-r8635.jar
- javax.persistence_2.0.1.v201006031150.jar
- eclipselink.jar

Eclipse generates a folder for the generated source code in the project folder (called "generated" -- I changed this from the default) but no classes inside that folder.

Thanks in advance for any help.

Code for the entity class:
/**
 * Copyright (c) 2010 Martin Geisse
 *
 * This file is distributed under the terms of the MIT license.
 */

package name.martingeisse.leckermittag.experiment;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 * A simple test entity for EclipseLink experiments.
 */
@Entity
public class Todo {

	/**
	 * the id
	 */
	private Long id;

	/**
	 * the summary
	 */
	private String summary;

	/**
	 * the description
	 */
	private String description;

	/**
	 * Constructor.
	 */
	public Todo() {
	}

	/**
	 * Getter method for the id.
	 * @return the id
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	/**
	 * Setter method for the id.
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * Getter method for the summary.
	 * @return the summary
	 */
	public String getSummary() {
		return summary;
	}

	/**
	 * Setter method for the summary.
	 * @param summary the summary to set
	 */
	public void setSummary(String summary) {
		this.summary = summary;
	}

	/**
	 * Getter method for the description.
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Setter method for the description.
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public String toString() {
		return "Todo [summary=" + summary + ", description=" + description + "]";
	}

}


(project)/src/META-INF/persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
	<persistence-unit name="todos" transaction-type="RESOURCE_LOCAL">
		<class>name.martingeisse.leckermittag.experiment.Todo</class>
		<properties>
			<!-- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" /> -->
			<!-- <property name="javax.persistence.jdbc.url" value="jdbc:derby:/home/vogella/databases/simpleDb;create=true" /> -->
			<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/leckerMittag" />
			<property name="javax.persistence.jdbc.user" value="postgres" />
			<property name="javax.persistence.jdbc.password" value="postgres" />

			<!-- EclipseLink should create the database schema automatically -->
			<!-- <property name="eclipselink.ddl-generation" value="create-tables" /> -->
			<!-- <property name="eclipselink.ddl-generation.output-mode" value="database" /> -->
			
		</properties>

	</persistence-unit>
</persistence>


(project)/src/META-INF/orm.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">

	<description>description here</description>
	<persistence-unit-metadata>
		<persistence-unit-defaults>
			<delimited-identifiers />
		</persistence-unit-defaults>
	</persistence-unit-metadata>

</entity-mappings>
Re: problems using metamodel generator in Eclipse [message #646737 is a reply to message #646732] Thu, 30 December 2010 16:47 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 470
Registered: July 2009
Senior Member
One thing you could try as an alternative would be the metamodel generation capabilities available in Dali Java Persistence Tools. These tools are integrated directly into Eclipse and do not require additional compiler configuration.

See the section called "JPA 2.0 Canonical Metamodel Generation" at the link below for more info.

http://www.eclipse.org/webtools/releases/3.2.0/NewAndNotewor thy/jpa.php

Dali is available via the Helios Software Site and is a part of the Web Tools project. It is included in the Helios Java EE package.

For more info on Dali - http://eclipse.org/webtools/dali/

Neil
Re: problems using metamodel generator in Eclipse [message #646765 is a reply to message #646737] Thu, 30 December 2010 19:42 Go to previous message
Martin Geisse is currently offline Martin GeisseFriend
Messages: 24
Registered: July 2009
Junior Member
That works. Thank you!
Previous Topic:ClassNotFoundException on create of TypedQuery
Next Topic:Using OneToMany or ManyToOne . A Performance issue
Goto Forum:
  


Current Time: Sun Dec 21 16:47:52 GMT 2014

Powered by FUDForum. Page generated in 0.01629 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software