Friday, July 13, 2012

JPA : Using Criteria API

Using the Criteria API to Create Queries

The Criteria API is used to define queries for entities and their persistent state by creating query-defining objects. Criteria queries are written using Java programming language APIs, are typesafe, and are portable. Such queries work regardless of the underlying data store.

Overview of the Criteria and Metamodel APIs

Similar to JPQL, the Criteria API is based on the abstract schema of persistent entities, their relationships, and embedded objects. The Criteria API operates on this abstract schema to allow developers to find, modify, and delete persistent entities by invoking Java Persistence API entity operations. The Metamodel API works in concert with the Criteria API to model persistent entity classes for Criteria queries.
The Criteria API and JPQL are closely related and are designed to allow similar operations in their queries. Developers familiar with JPQL syntax will find equivalent object-level operations in the Criteria API.
The following simple Criteria query returns all instances of the Car entity in the data source:
EntityManager em = ...;
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(Car.class);
Root car= cq.from(Car.class);
cq.select(car);
TypedQuery q = em.createQuery(cq);
List allCars = q.getResultList();
The equivalent JPQL query is:
SELECT c
FROM Car c
This query demonstrates the basic steps to create a Criteria query:
  1. Use an EntityManager instance to create a CriteriaBuilder object.
  2. Create a query object by creating an instance of the CriteriaQuery interface. This query object's attributes will be modified with the details of the query.
  3. Set the query root by calling the from method on the CriteriaQuery object.
  4. Specify what the type of the query result will be by calling the select method of the CriteriaQuery object.
  5. Prepare the query for execution by creating a TypedQuery instance, specifying the type of the query result.
  6. Execute the query by calling the getResultList method on the TypedQuery object. Because this query returns a collection of entities, the result is stored in a List.
The tasks associated with each step are discussed in detail in this chapter.
To create a CriteriaBuilder instance, call the getCriteriaBuilder method on the EntityManager instance:
CriteriaBuilder cb = em.getCriteriaBuilder();
The query object is created by using the CriteriaBuilder instance:
CriteriaQuery cq = cb.createQuery(Car.class);
The query will return instances of the Pet entity, so the type of the query is specified when the CriteriaQuery object is created to create a typesafe query.
The FROM clause of the query is set, and the root of the query specified, by calling the from method of the query object:
Root pet = cq.from(Car.class);
The SELECT clause of the query is set by calling the select method of the query object and passing in the query root:
cq.select(car);
The query object is now used to create a TypedQuery object that can be executed against the data source. The modifications to the query object are captured to create a ready-to-execute query:
TypedQuery q = em.createQuery(cq);
This typed query object is executed by calling its getResultList method, because this query will return multiple entity instances. The results are stored in a List collection-valued object.
List allCars = q.getResultList();

 

For Example:

Simple Query


Query query = entityManager.createQuery("from SimpleBean s");
List list = query.getResultList();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery criteriaQuery = criteriaBuilder.createQuery();
Root from = criteriaQuery.from(SimpleBean.class);
CriteriaQuery select = criteriaQuery.select(from);
TypedQuery typedQuery = entityManager.createQuery(select);
List resultList = typedQuery.getResultList();
assertEqualsList(list, resultList);
 

Simple Query with Order


List expected= entityManager.createQuery("from SimpleBean s order by s.pbyte asc ,s.pint desc")
                                  .getResultList();
 
//...
CriteriaQuery select = criteriaQuery.select(from);
        select.orderBy(criteriaBuilder.asc(from.get("pbyte"))
                        ,criteriaBuilder.desc(from.get("pint")));
TypedQuery typedQuery = entityManager.createQuery(select);
       //...
 

Simple Query with selected fields


Query query = entityManager.createQuery("select s.id,s.pbyte from SimpleBean s ");
List listExpected = query.getResultList();
        //...
CriteriaQuery select = criteriaQuery.multiselect(from.get("id"),from.get("pbyte"));
 
 

Query with single criteria


int arg1 = 20000;
Query query = entityManager.createQuery("from SimpleBean s where s.pint>=:arg1");
query.setParameter("arg1", arg1);
List list = query.getResultList();
 
//...
CriteriaQuery select = criteriaQuery.select(from);
 
Predicate predicate = criteriaBuilder.ge(from.get("pint"), arg1);
criteriaQuery.where(predicate);
//...
 
 

Query with multiple criterias


int arg1 = 20000;
int arg2 = 50000;
Query query = entityManager.createQuery("from SimpleBean s where s.pint>=:arg1 and s.pint<=:arg2");
query.setParameter("arg1", arg1);
query.setParameter("arg2", arg2);
List list = query.getResultList();
 
//..
Predicate predicate1 = criteriaBuilder.ge(from.get("pint"), arg1);
Predicate predicate2 = criteriaBuilder.le(from.get("pint"), arg2);
criteriaQuery.where(criteriaBuilder.and(predicate1, predicate2));
//..
 
 

Query with aggreation (group by)


Query query = entityManager.createQuery("select min(s.pint),s.pbyte from SimpleBean s group by s.pbyte");
 
List listExpected = query.getResultList();
 
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery criteriaQuery = criteriaBuilder.createQuery();
Root from = criteriaQuery.from(SimpleBean.class);
 
Expression minExpression = criteriaBuilder.min(from.get("pint"));
Path pbytePath = from.get("pbyte");
CriteriaQuery select = criteriaQuery.multiselect(minExpression, pbytePath);
 
CriteriaQuery groupBy = select.groupBy(pbytePath);
 
TypedQuery typedQuery = entityManager.createQuery(select);
List listActual = typedQuery.getResultList();
 
 
with the help of:
http://docs.oracle.com/javaee/
http://en.wikibooks.org/wiki/Java_Persistence/Querying

JPA 2.0

1. JPA

1.1. Overview

The process of mapping Java objects to database tables and vice versa is called "Object-relational mapping" (ORM).
The Java Persistence API (JPA) is one possible approach to ORM. JPA is a specification and several implementations are available. Popular implementations are Hibernate, EclipseLink and Apache OpenJPA. The reference implementation of JPA is EclipseLink.
Via JPA the developer can map, store, update and retrieve data from relational databases to Java objects and vice versa.
JPA permits the developer to work directly with objects rather then with SQL statements. The JPA implementation is typically called persistence provider. JPA can be used in Java-EE and Java-SE applications.
The mapping between Java objects and database tables is defined via persistence metadata. The JPA provider will use the persistence metadata information to perform the correct database operations.
JPA typically defines the metadata via annotations in the Java class. Alternatively the metadata can be defined via XML or a combination of both. A XML configuration overwrites the annotations.
The following description will be based on the usage of annotations.
JPA defines a SQL-like Query language for static and dynamic queries.
Most JPA persistence provider offer the option to create automatically the database schema based on the metadata.

1.2. Entity

A class which should be persisted in a database it must be annotated with javax.persistence.Entity. Such a class is called Entity. JPA will create a table for the entity in your database. Instances of the class will be a row in the table.
All entity classes must define a primary key, must have a non-arg constructor and or not allowed to be final. Keys can be a single field or a combination of fields.
JPA allows to auto-generate the primary key in the database via the @GeneratedValue annotation.
By default, the table name corresponds to the class name. You can change this with the addition to the annotation @Table(name="NEWTABLENAME").

1.3. Persistence of fields

The fields of the Entity will be saved in the database. JPA can use either your instance variables (fields) or the corresponding getters and setters to access the fields. You are not allowed to mix both methods. If you want to use the setter and getter methods the Java class must follow the Java Bean naming conventions. JPA persists per default all fields of an Entity, if fields should not be saved they must be marked with @Transient.
By default each field is mapped to a column with the name of the field. You can change the default name via @Column (name="newColumnName").
The following annotations can be used.

1.4. Relationship Mapping

JPA allows to define relationships between classes, e.g. it can be defined that a class is part of another class (containment). Classes can have one to one, one to many, many to one, and many to many relationships with other classes.
A relationship can be bidirectional or unidirectional, e.g. in a bidirectional relationship both classes store a reference to each other while in an unidirectional case only one class has a reference to the other class. Within a bidirectional relationship you need to specify the owning side of this relationship in the other class with the attribute "mappedBy", e.g. @ManyToMany(mappedBy="attributeOfTheOwningClass".

1.5. Entity Manager

The entity manager javax.persistence.EntityManager provides the operations from and to the database, e.g. find objects, persists them, remove objects from the database, etc. In a JavaEE application the entity manager is automatically inserted in the web application. Outside JavaEE you need to manage the entity manager yourself.
Entities which are managed by an Entity Manager will automatically propagate these changes to the database (if this happens within a commit statement). If the Entity Manager is closed (via close()) then the managed entities are in a detached state. If synchronize them again with the database a Entity Manager provides the merge() method.
The persistence context describes all Entities of one Entity manager.

1.6. Persistence Units

The EntityManager is created by the EntitiyManagerFactory which is configured by the persistence unit. The persistence unit is described via the file "persistence.xml" in the directory META-INF in the source folder. A set of entities which are logical connected will be grouped via a persistence unit. "persistence.xml" defines the connection data to the database, e.g. the driver, the user and the password,


2. Simple Example

2.1. Project and Entity

Create a java Project. Create a folder "lib" and place the required JPA jars and derby.jar into this folder.

package web.com.jpamodel;

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

@Entity
public class DoSomething{
 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 private Long i;
 private String a;
 private String b;

 public String getA() {
  return summary;
 }

 public void setA(String A) {
  this.summary = summary;
 }

 public String getB() {
  return description;
 }

 public void setB(String B) {
  this.description = description;
 }


} 

3. Relationship Example

Create a Java project, create again a folder "lib" and place the required JPA jars and derby.jar into this folder.


package web.com.jpamodel;

import java.util.ArrayList;
import java.util.List;

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

@Entity
public class Family {
 @Id
 @GeneratedValue(strategy = GenerationType.TABLE)
 private int id;
 private String description;

 @OneToMany(mappedBy = "family")
 private final List members = new ArrayList();

 public int getId() {
  return id;
 }

 public void setId(int id) {
  this.id = id;
 }

 public String getDescription() {
  return description;
 }

 public void setDescription(String description) {
  this.description = description;
 }

 public List getMembers() {
  return members;
 }

} 



 /**********************************************************************/

package web.com.jpamodel;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

@Entity
public class Person {
 @Id
 @GeneratedValue(strategy = GenerationType.TABLE)
 private String id;
 private String firstName;
 private String lastName;

 private Family family;

 private String nonsenseField = "";

 private List jobList = new ArrayList();

 public String getId() {
  return id;
 }

 public void setId(String Id) {
  this.id = Id;
 }

 public String getFirstName() {
  return firstName;
 }

 public void setFirstName(String firstName) {
  this.firstName = firstName;
 }

 // Leave the standard column name of the table
 public String getLastName() {
  return lastName;
 }

 public void setLastName(String lastName) {
  this.lastName = lastName;
 }

 @ManyToOne
 public Family getFamily() {
  return family;
 }

 public void setFamily(Family family) {
  this.family = family;
 }

 @Transient
 public String getNonsenseField() {
  return nonsenseField;
 }

 public void setNonsenseField(String nonsenseField) {
  this.nonsenseField = nonsenseField;
 }

 @OneToMany
 public List getJobList() {
  return this.jobList;
 }

 public void setJobList(List nickName) {
  this.jobList = nickName;
 }

} 

 /***********************************************************************/
package web.com.jpamodel;


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

@Entity
public class Job {
 @Id
 @GeneratedValue(strategy = GenerationType.TABLE)
 private int id;
 private double salery;
 private String jobDescr;

 public int getId() {
  return id;
 }

 public void setId(int id) {
  this.id = id;
 }

 public double getSalery() {
  return salery;
 }

 public void setSalery(double salery) {
  this.salery = salery;
 }

 public String getJobDescr() {
  return jobDescr;
 }

 public void setJobDescr(String jobDescr) {
  this.jobDescr = jobDescr;
 }

} 
 

Saturday, March 24, 2012

Rajyana Manacha mujara..!!!

दुरावा


दुरावा वाढला तरीही,
मी तुला विसरलोच नाही..,
मनाताल्या भावना हरवल्या तरीही,
हृदयातील प्रेम संपलेच नाही...!!!

Thursday, March 8, 2012

College Days.


Everyday we come,
Class teacher enters,

Good Morning...!!!

He asks to sit, a smile!
I came late(as usual)
her mood is hot, she warms..,

Teacher throws a questions,
unable I am answer,
EveryOne Look at me, they all Laugh.
I felt ashamed...!!!

Dp I not know..???
Our college days go by,
we shall not meet again,
EveryOne is in grief, in pain..,

Departing time,
Mind suffers,
Heart shivers..,

Eyes filled with tears...!!!



Monday, December 26, 2011

Expectations..!!!


Expect more from yourself than from others.
Because, expectation from others hurts a lot,
while expectation from yourself inspires a lot.

Good Morning - It makes a lot of difference in life..!!!


It's not what you have in your life but who you have in your life that counts.

Don't be close to someone who makes u happy...

Be close to someone who can't be happy without u...

It makes a lot of difference in life......!

Thursday, December 15, 2011

Year’s End

Now winter downs the dying of the year,
And night is all a settlement of snow;
From the soft street the rooms of houses show
A gathered light, a shapen atmosphere,
Like frozen-over lakes whose ice is thin
And still allows some stirring down within.

I’ve known the wind by water banks to shake
The late leaves down, which frozen where they fell
And held in ice as dancers in a spell
Fluttered all winter long into a lake;
Graved on the dark in gestures of descent,
They seemed their own most perfect monument.

There was perfection in the death of ferns
Which laid their fragile cheeks against the stone
A million years. Great mammoths overthrown
Composedly have made their long sojourns,
Like palaces of patience, in the gray
And changeless lands of ice. And at Pompeii

The little dog lay curled and did not rise
But slept the deeper as the ashes rose
And found the people incomplete, and froze
The random hands, the loose unready eyes
Of men expecting yet another sun
To do the shapely thing they had not done.

These sudden ends of time must give us pause.
We fray into the future, rarely wrought
Save in the tapestries of afterthought.
More time, more time. Barrages of applause
Come muffled from a buried radio.
The New-year bells are wrangling with the snow.

नकळत कहितरि घडावे...........!

हुल्लड बालपन खेळातच रमाव
परिस॑गे जादुच्या दुनियेत शिराव
सदा मनि एकच विचार.....वाटते....
अदभुत कहितरि घडाव नकळ्त आज.

अभ्यासाचा बोजा तोच अवघड ग्रुह्पाठ
रोज रोज लिहुनि थकावे मग दुखते पाठ
कसि सुटि मिळेल शाळेला हा एकच विचार
नकळ्त घडावे कहितरि वाट्ते आज.

मग तारुन्यपन येत मिसरुड फुट्त ओठावर
वहि बोटावरुन फिरवताना मुलिकडे बघाव रोज
तिच्या होकारासाठि सतत ठरलेला पाठलाग
नैतिकतेचे भाषण देउन प्राध्यापक मग थकतात
सार कहि निरथक चा॑गल राहत बाजुला
नकळ्त घडावे कहितरि वाट्ते आज मला.

पदविधर होताच हि॑डावे नोकरिसाठि दाहिदिशा
सततचा नकार एकुनि जिव होइ वेडापिसा
काय शिकलो? किति शिकलो? याच गणित तेव्हा कराव
वेळेच महत्त्व किति असत याच भान तेव्हा उमजुन याव
अन चाहुल लागावि मनि दुखि होउनि
नकळ्त घडावे कहितरि वाट्ते आज मनि.

दिवसामागुन दिवस जातात वय उलटु लागत
जबाबदारिच ओझ जड होतच राहत
नकळ्त पानावतात डोळे तिचा चेहरा उभा राह्तो
कुठे असेल ति मन भुतकाळात डोकाउ लागत
एक अत्रुप्त इछ्या तिच्या सोबत जगन्याचि
गुदमरुन टाकते या जातिच्या पगड्यात
क्षणात ह्रुदय पिळवटुन निघत...
नकळ्त घडावे कहितरि वाट्ते आज.

बापाच नात मग जपाव लागत
त्या हळ्व्या क्षणा॑नि मन चिम्भ भिजुन जात
आपल बालपन आठ्वु लागत आपल्या मुलात तेव्हा
असेच होतो ना आपण हट्टि त्या वेळेला
सार कस उन्म्ळुन येत एकापाठोपठ एक
अन वाट्ते नकळत कहितरि घडावे आज.

मग अ॑ग थकत सार काहि थकत क्षिण होउन जात शरिर
नजरेसमोर दिसु लागत म्रुत्युच भयान प्रतिबिम्ब
हाति येते काठि तोच एकमेव आधार
सार काहि सुन सुन मावळत जाणारि स॑न्द्याकाळ
उशाकाल होइल का?.....चक्र असे हे नशिबाचे
तरिहि या स॑पलेल्या वळ्णावर कुठेतरि उगाचच का वाट्ते
नकळत कहितरि घडावे...........!
नकळत कहितरि घडावे ..........!

मैत्री

मैत्री एक गांव असत
आणी मैत्रिण हे त्याहून सुन्दर नाव असत
हे नाव असत आनंदाच ...........
नाव असत दिलेल्या धीराच,
मदतीच्या हाताच ..........

आयुष्यातल्या आनंदघनाच
मैत्रिण हे नाव असत
वरवर साध वाटल
तरी काळजाचा ठाव असत......

आपल्या मनाला आपणच आवरायचं असतं...!!!

गंध आवडला फुलाचा म्हणून... ... फूल मागायचं नसतं.
गंध आवडला फुलाचा म्हणून
फूल मागायचं नसतं
अशा वेळी आपल्या मनाला आपणच आवरायचं असतं....


परक्यांपेक्षा आपलीच माणसं
आपल्याला नेहमी दगा देतात
एकमेकांच्या पाठीवर मग्
नजरे आडून वार होतात


भळभळणा-या जखमेतून
विश्वास घाताचं रक्त वाहतं
छिन्नविछीन्न जखमेला तेव्हा
आपणच पुसायचं असतं

अशा वेळी आपल्या मनाला आपणच आवरायचं असतं....

आपलं सुःख पाहण्याचा तसा
प्रत्येकाला अधिकार आहे..
पण्; दुस-याला मारुन जगणं
हा कुठला न्याय आहे...

माणूस म्हणुन माणसावर
खरं प्रेम करायचं
आपल्या साठी थोडं,
थोडं दुस-यासाठी जगायचं

जगण्याचं हे ध्येय मनात आपणच बाणवायचं आसतं
अशा वेळी आपल्या मनाला आपणच आवरायचं असतं....

आपल्याला कोणी आवडणं
हे प्रत्येक वेळी च प्रेम नसतं
आकर्षणाचं स्वप्नं ते
आकर्षणंच असतं...

मान्य आहे,
आकर्षणात प्रेम केव्हा केव्हा दिसतं...
पण् जे चकाकतं
ते प्रत्येक् वेळीच् सोनं नसतं


मन् आपलं वेडं असतं
वेडं आपण व्हायचं नसतं..
मन मारुन जगण्यापेक्षा
वेळीच त्याला आवरायचं

अशावेळी....
आणि अशाच वेळी आपल्या मनाला आपणच आवरायचं असतं...

Monday, September 5, 2011

Trekking @ PEB : "The clearest way into the universe is through a forest wilderness."





vakratu.nDa mahaakaaya...

vakratu.nDa mahaakaaya koTisuuryasamaprabha |
nirvighnaM kuru me deva sarvakaaryeshhu sarvadaa ||

II Meaning of Shree Ganesha Shloka II

O God Ganesha (large bodied with a large belly), radiant as millions of Suns, Please, remove obstacles in all of my tasks all the time

GANESH GAYATHRI

Tatpurushaaya Vidmahe
Vakratundaaya Dheemahe
Tanno Danthihi Prachodayaat


Meaning: We meditate on that super power, we invoke the single tusked boon giver, Ganesh.

Ganapati Bappa Morya...!!!

Lord Ganesha is the one of the most popular gods of the Hindu Religion. Ganesh is known as the eradicator of obstacles and god of beginnings. Lord Ganesha is considered as the first god to be worshipped. Slokas on Lord Ganesha form the part of prayers offered to the lord. Here is a collection of Ganesha Shlokas:


"Shuklaambara Dharam Vishnum, Shashi Varnam Chatur Bhujam
Prasanna Vadanam Dhyaayet, Sarva Vighna Upashaanthaye"


Meaning: Lord Ganesha always dressed in white represents purity. He is omnipresent with gray complexion like that of ash glowing with spiritual splendor. The Lord with bright countenance has four arms. I meditate on the God who can destroy all obstacles whether material or spiritual.

"Vakratunda Mahakaaya, Suryakoti Samaprabha
Nirvighnam Kuru Mey Deva, Sarva Kaaryeshu Sarvada"

Meaning: Lord Ganesha has a curved trunk with a powerful body. He has the brilliance of a million suns. May the Lord, remove all the problems from the actions I aim to achieve.

"Ekadantam Mahaakaayan, Taptakaajnchanasannibhamh
Lambodaram Vishaalaaxam, Vandeaham Gananaayakamh"

Meaning: Obeisance to Lord Ganesha, the one tusked, huge-bodied, big-bellied, and large-eyed God, whose complexion is like that of molten gold. I surrender myself to such great lord.

"Srikantho Mathulo Yasya, Jananee Sarva Mangalaa
Janakaha Sankaro Devaha, Tam Vande' Kunjaraananam"

Meaning: The lord, for whom Lord Vishnu is the Uncle, whose mother is the divine auspicious one, Parvati and whose father is Lord Shiva. I offer salutations to Sri Ganesha, the Omkara.

"Prasanna Vinaayakam Devam, Perivana Pura Samsthitham
Sarva Vigna Haram Nithyam, Vandhe Sri Kunjaraananam"

Meaning: The Lord Sri Prasanna Vinaayaka, who lives in his Temple of Pearland; one who removes all obstacles of all his devotees at all times; one who has the Omkara face of the elephant. I pray to the divine Ganesha.

"Agajaanana Padmaarkam, Gajaananam Aharnisham
Anekadantham Bhaktaanaam, Ekadantam Upaasmahey"

Meaning: Lord Ganesha, the elephant faced is like sun to the lotus face of Mother Parvati. The single tusked Ganesha is the giver of boons. I salute the great lord to grant us a boon.

"Ganaanaam Twam Ganapathi Gam Havaamahe
Kavim Kaveenaam Upamasra Vastamam
Jyeshta Raajam Brahmanaam Brahmanaspatha
Aanashrunvanna Oothibhi Seedha Saadanam"

Meaning: The Lord of spiritual faith, son of Lord Shiva, is the wisest among the wise. Ganesha has no comparison. He is the senior Lord of the Vedic mantras, who listens to the devotee's prayers. I invite Lord Ganesha to visit my home with prosperous things and be seated here.

Ganapati Bappa Morya...!!!





Monday, July 4, 2011

The Snow Man

One must have a mind of winter
To regard the frost and the boughs
Of the pine-trees crusted with snow;

And have been cold a long time
To behold the junipers shagged with ice,
The spruces rough in the distant glitter

Of the January sun; and not to think
Of any misery in the sound of the wind,
In the sound of a few leaves,

Which is the sound of the land
Full of the same wind
That is blowing in the same bare place

For the listener, who listens in the snow,
And, nothing himself, beholds
Nothing that is not there and the nothing that is.

Come Lord and Lift

Come Lord, and lift the fallen bird
Abandoned on the ground;
The soul bereft and longing so
To have the lost be found.

The heart that cries—let it but hear
Its sweet love answering,
Or out of ether one faint note
Of living comfort wring.

"Come Lord and Lift" is one of my favorite poems by a contemporary poet

Distant light

Harsh and cold
autumn holds to it our naked trees:
If only you would free, at least, the sparrows
from the tips of your fingers
and release a smile, a small smile
from the imprisoned cry I see.
Sing! Can we sing
as if we were light, hand in hand
sheltered in shade, under a strong sun?
Will you remain, this way
stoking the fire, more beautiful than necessary, and quiet?
Darkness intensifies
and the distant light is our only consolation —
that one, which from the beginning
has, little by little, been flickering
and is now about to go out.
Come to me. Closer and closer.
I don't want to know my hand from yours.
And let's beware of sleep, lest the snow smother us.

Bread and Music

Music I heard with you was more than music,
And bread I broke with you was more than bread;
Now that I am without you, all is desolate;
All that was once so beautiful is dead.

Your hands once touched this table and this silver,
And I have seen your fingers hold this glass.
These things do not remember you, belovèd,
And yet your touch upon them will not pass.

For it was in my heart you moved among them,
And blessed them with your hands and with your eyes;
And in my heart they will remember always,—
They knew you once, O beautiful and wise.