• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/8

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

8 Cards in this Set

  • Front
  • Back
"property from @OrderBy clause not found" means what?
Hibernate's errors are often confusing, telling you about the referenced table but not the file (table) where the annotation actually exists that is causing problems. Usually, the orderby clause is referencing another, external table and telling it what column in the other table to order a list by. The best thing to do is search for "OrderBy.*nameOfPropertyNotFound" where nameOfPropertyNotFound is something provided in the error.
What is the @OrderBy annotation for?
It tells how to order a list (what column to sort by, and save sort order by).
@JoinColumn - explained; (also @JoinColumns).
Often used with @ManyToOne and @OneToMany, but usually not in both places. Defines the column used to join the two entities, or a join table for many-to-many relationships. It can be contained inside an array of several of these.

parameters:
name: the column name
nullable: whether null values are allowed.
unique: whether it's a unique key
@OneToMany annotation. What is it, what are its parameters, where does it belong, and what is the result for the given table and the referenced table?
It means that the current entity has many items (in a list, usually) of another entity. Think of these annotations as "One (of this) to many (of those)".

cascade - what types of operations should affect the referenced entities (such as deletions, etc)
mappedBy - tells which column in the *other* entity refers to *this* entity. Usually, this will look like the current entity is referring to itself.
fetch - whether to get the other items eagerly or later as-needed by default.
Explain how to use the @ManyToMany annotation
Here's an example from the Oracle documentation at http://docs.oracle.com/javaee/6/api/javax/persistence/ManyToMany.html

// In Customer class:

@ManyToMany
@JoinTable(name="CUST_PHONES")
public Set<PhoneNumber> getPhones() { return phones; }

// In PhoneNumber class:

@ManyToMany(mappedBy="phones")
public Set<Customer> getCustomers() { return customers; }
hql: how do you sort by two columns?
"from EntityName order by col1 asc, col2 asc";

You should be sure to capitalize the entity name; you're not using the table name, but the class name. I think.
hql for converting numeric or temporal values to a readable string
str()
How do you add and remove items from a Collection? Why? What should you NOT do?
Do this:
myEntity.getC().addAll(otherCollection);

You should NOT do this:
myEntity.setC(otherCollection);

The reason is that the collection is a hibernate-managed bag, that keeps track of changes being made. Thus, if you add to/remove from the existing collection, the changes can be safely saved; yet if you set a new collection then Hibernate will throw an error (that usually isn't very helpful).