openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wendyLG <wendy.gibb...@thecitysecret.com>
Subject Re: beans, Enitiy annotation and bytcode enhancement
Date Mon, 09 Aug 2010 08:17:29 GMT

This is the simplest i can manange:

@Entity(name="testTable")
@Table(name = "test_table", catalog = "lcw")
public class TestBean {

	int	id;
	String data1;
	String data2;
	
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public int getId() {
		return id;
	}
	
	public void setId(int id_) {
		id = id_;
	}
	
	@Column(name="data_1")
	public String getData1() {
		return data1;
	}
	
	public void setData1(String data1_) {
		data1 = data1_;
	}
	
	@Column(name="data_2")
	public String getData2() {
		return data2;
	}
	
	public void setData2(String data2_) {
		data2 = data2_;
	}
	
}

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/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_1_0.xsd">
	<persistence-unit name="LCWCommonPU">
		<class>test.program.TestBean</class>
		
		<properties>
			<property name="openjpa.ConnectionDriverName"
				value="com.mysql.jdbc.Driver" />
			<property name="openjpa.ConnectionDriverName"
value="com.mysql.jdbc.Driver" />
			<property name="openjpa.ConnectionURL"
value="jdbc:mysql://localhost:3306/lcw" />
			<property name="openjpa.ConnectionUserName" value="***" />
			<property name="openjpa.ConnectionPassword" value="****" />
			<property name="openjpa.jdbc.UpdateManager" value="operation-order"/>
			<property name="openjpa.DataCache" value="true" />
			<property name="openjpa.RemoteCommitProvider" value="sjvm" />
 			<property name="openjpa.DataCacheTimeout" value="100000" />
		</properties>
	</persistence-unit>

</persistence>

public class UnitTestBean {

	private static EntityManagerFactory emf;
	private static ThreadLocal<EntityManager> threadLocal;
	
	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testOne() {
		emf = Persistence.createEntityManagerFactory("LCWCommonPU");
		System.err.println("EMF:" + emf);
		threadLocal = new ThreadLocal<EntityManager>();
		final String queryString;
		queryString = "select model from testTable model order by model.id";
		Query query = getEntityManager().createQuery(queryString);
		List resultList = query.getResultList();
	}

	private EntityManager getEntityManager() {
		EntityManager manager = threadLocal.get();
		if (manager == null || !manager.isOpen()) {
			manager = emf.createEntityManager();
			threadLocal.set(manager);
		}
		return manager;
	}
}

<openjpa-1.2.2-r422266:898935 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: An error occurred while
parsing the query filter "select model from testTable model order by
model.id". Error message: The name "testTable" is not a recognized entity or
identifier. Perhaps you meant TestBean, which is a close match. Known entity
names: [TestBean]

This very test worked before i added bytecode enahncement.
my enchancement options:
http://openjpa.208410.n2.nabble.com/file/n5388167/bytecode.jpg 


-- 
View this message in context: http://openjpa.208410.n2.nabble.com/beans-Enitiy-annotation-and-bytcode-enhancement-tp5380244p5388167.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Mime
View raw message