@Entity
@Table(name = "mm_log", catalog = "mmud", schema = "")
@NamedQueries(
{
@NamedQuery(name = "Log.findAll", query = "SELECT l FROM Log l"),
@NamedQuery(name = "Log.findByName", query = "SELECT l FROM Log l WHERE l.name = :name"),
@NamedQuery(name = "Log.findByMessage", query = "SELECT l FROM Log l WHERE l.message = :message")
})
public class Log implements Serializable
@Table(name = "mm_log", catalog = "mmud", schema = "")
@NamedQueries(
{
@NamedQuery(name = "Log.findAll", query = "SELECT l FROM Log l"),
@NamedQuery(name = "Log.findByName", query = "SELECT l FROM Log l WHERE l.name = :name"),
@NamedQuery(name = "Log.findByMessage", query = "SELECT l FROM Log l WHERE l.message = :message")
})
public class Log implements Serializable
Notice the catalog and the schema in the annotation for Table?
Now, it turns out1 that "schema" is unsupported in MySQL, and "catalog", apparently, is just a fancy way in MySQL of saying "database".
So, if I create a brand new database (call it "newmmud"), create a nice JDBC Connection Pool to it in my Glassfish server, yet this blasted Entity (Log, in the example) will still refer to the database "mmud"!
That's what I call confusing!
Here's the message, for posterity's sake:
“You're correct. For legacy reasons (including compatibility with ODBC, and SQL Server), JDBC's concept of "catalog" maps to MySQL's concept of "databases".- Mark Matthews
Starting in MySQL-4.1, "schema" is an alias for "database", but it doesn't act like a SQL-standard schema, so we don't support the concept in the JDBC driver.”
References
- [1] Forum - Re: catalog versus schema
- http://forums.mysql.com/read.php?39,137564,137629#msg-137629
No comments:
Post a Comment