Galera, dei uma mudada no codigo seguindo o conselho do amigo sobre java Null exceptio, mas deu um outro erro.
package views;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Query;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.text.MaskFormatter;
import Beans.cliente_locadora;
import Beans.reserva_locadora;
@SuppressWarnings("serial")
public class CopyOfBuscaCliente extends JFrame{
JLabel rotulo1, rotulo3, rotulo4, rotulo5;
JButton consultar;
JTextField nome_cli;
private static EntityManagerFactory f = null;
public CopyOfBuscaCliente(EntityManagerFactory f1){
super("LOCADORA YASMIN");
getContentPane().setForeground(new Color(30, 144, 255));
getContentPane().setLayout(null);
Container tela = getContentPane();
setLayout(null);
f=f1;
tela.setBackground(new Color(181,181,181));
rotulo1 = new JLabel ("Nome:");
rotulo1.setBounds(10, 50, 110, 30);
rotulo3 = new JLabel ("Código do cliente:");
rotulo3.setBounds(10, 101, 150, 30);
rotulo4 = new JLabel ("Celular:");
rotulo4.setBounds(181, 156, 110, 30);
rotulo5 = new JLabel ("Fone:");
rotulo5.setBounds(10, 156, 110, 30);
nome_cli = new JTextField (5);
nome_cli.setBounds(67, 53, 142, 25);
consultar = new JButton ("Consultar");
consultar.setBounds(235, 54, 90, 23);
tela.add(rotulo1);
tela.add(rotulo3);
tela.add(rotulo4);
tela.add(rotulo5);
tela.add(nome_cli);
tela.add(consultar);
// DESABILITAM-SE ALGUNS BOTÕES
consultar.setEnabled(true);
setSize(360, 309);
setVisible(true);
setLocationRelativeTo(null);// CENTRALIZA A JANELA
// Ações Botões
consultar.addActionListener(
new ActionListener(){
public void actionPerformed(final ActionEvent e){
if(!nome_cli.getText().trim().equals("")){
cliente_locadora d = new cliente_locadora();
List<cliente_locadora> cliente = new ArrayList<cliente_locadora>();
StringBuilder jpql = new StringBuilder("SELECT c FROM cliente_locadora c WHERE c.nome_cli = :"+ nome_cli);
EntityManager em = f.createEntityManager();
Query q = em.createQuery(jpql.toString());
q.setParameter("nome_cli", nome_cli);
List<cliente_locadora> resultados = q.getResultList();
if (nome_cli != null && !nome_cli.equals("")) {
rotulo3.setText(String.valueOf(d.getCod_cli()));
rotulo4.setText(d.getFone_residencial());
rotulo5.setText(d.getCelular());
}
else {
JOptionPane.showMessageDialog(null, "Cliente não encontrado!");
}
}
}
public void focusGained(final FocusEvent arg0) {
// TODO Auto-generated method stub
}
} // fim do new ActionListener
);
}
}
- Hibernate Annotations 3.3.0.GA
- Hibernate 3.2.5
- hibernate.properties not found
- Bytecode provider name : cglib
- using JDK 1.4 java.sql.Timestamp handling
- Hibernate EntityManager 3.3.1.GA
- Binding entity from annotated class: Beans.cliente_locadora
- Bind entity Beans.cliente_locadora on table cliente_locadora
- Binding entity from annotated class: Beans.funcionario_locadora
- Bind entity Beans.funcionario_locadora on table funcionario_locadora
- Binding entity from annotated class: Beans.filme_locadora
- Bind entity Beans.filme_locadora on table filme_locadora
- Binding entity from annotated class: Beans.locacao_locadora
- Bind entity Beans.locacao_locadora on table locacao_locadora
- Binding entity from annotated class: Beans.devolver_filme
- Bind entity Beans.devolver_filme on table devolver_filme
- Binding entity from annotated class: Beans.reserva_locadora
- Bind entity Beans.reserva_locadora on table reserva_locadora
- Hibernate Validator 3.0.0.GA
- Using Hibernate built-in connection pool (not for production use!)
- Hibernate connection pool size: 20
- autocommit mode: true
- using driver: oracle.jdbc.OracleDriver at URL: jdbc:oracle:thin:@127.0.0.1:1521
- connection properties: {user=system, password=****, autocommit=true, release_mode=auto}
- RDBMS: Oracle, version: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
- JDBC driver: Oracle JDBC driver, version: 10.2.0.1.0XE
- Using dialect: org.hibernate.dialect.Oracle9Dialect
- The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead
- Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
- No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
- Automatic flush during beforeCompletion(): disabled
- Automatic session close at end of transaction: disabled
- JDBC batch size: 15
- JDBC batch updates for versioned data: disabled
- Scrollable result sets: enabled
- JDBC3 getGeneratedKeys(): disabled
- Connection release mode: auto
- Maximum outer join fetch depth: 3
- Default batch fetch size: 1
- Generate SQL with comments: disabled
- Order SQL updates by primary key: disabled
- Order SQL inserts for batching: disabled
- Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
- Using ASTQueryTranslatorFactory
- Query language substitutions: {}
- JPA-QL strict compliance: enabled
- Second-level cache: enabled
- Query cache: disabled
- Cache provider: org.hibernate.cache.NoCacheProvider
- Optimize cache for minimal puts: disabled
- Structured second-level cache entries: disabled
- Statistics: disabled
- Deleted entity synthetic identifier rollback: disabled
- Default entity-mode: pojo
- Named query checking : enabled
- building session factory
- Not binding factory to JNDI, no JNDI name configured
- Running hbm2ddl schema update
- fetching database metadata
- updating schema
- table found: SYSTEM.CLIENTE_LOCADORA
- columns: [dep_nome, data_exp, orgao_exp, nome_cli, datanascimento, rg, profissao, cpf, fone_residencial, cod_cli, fone_comercial, celular]
- foreign keys: []
- indexes: [sys_c007507]
- table found: SYSTEM.DEVOLVER_FILME
- columns: [nome_func, data_loc, cod_filme, dependente, titulo, nome_cli, devolvido, valor_loc, data_prevista, cod_loc, cod_cli, cod_func]
- foreign keys: []
- indexes: [sys_c007514]
- table found: SYSTEM.FILME_LOCADORA
- columns: [cod_filme, duracao, titulo, midia, genero, tema, ano, qtde_total, faixa_preco]
- foreign keys: []
- indexes: [sys_c007517]
- table found: SYSTEM.FUNCIONARIO_LOCADORA
- columns: [nome_func, dat_nasc, uf, sexo, rg, senha, cod_func, bairro, cidade, cep, telefone, cpf, login, conf_senha, end, celular]
- foreign keys: []
- indexes: [sys_c007519]
- table found: SYSTEM.LOCACAO_LOCADORA
- columns: [data_loc, cod_filme, desconto, titulo, quantidade, valor, data_devolucao, data_prevista, cod_cli, cod_loc]
- foreign keys: []
- indexes: [sys_c007524]
- table found: SYSTEM.RESERVA_LOCADORA
- columns: [id, reservar_para, cod_filme, cod_reserva, obs_reserva, cod_cli, cod_fuc]
- foreign keys: []
- indexes: [sys_c007529]
- schema update complete
- line 1:83: unexpected token: ,
- line 1:86: expecting CLOSE_BRACKET, found ','
- line 1:89: unexpected token: ,
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: org.hibernate.QueryException: unexpected char: '@' [SELECT c FROM Beans.cliente_locadora c WHERE c.nome_cli = :javax.swing.JTextField[,67,53,142x25,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@1e1962d,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=5,columnWidth=0,command=,horizontalAlignment=LEADING]]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:617)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96)
at views.CopyOfBuscaCliente$1.actionPerformed(CopyOfBuscaCliente.java:124)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.hibernate.QueryException: unexpected char: '@' [SELECT c FROM Beans.cliente_locadora c WHERE c.nome_cli = :javax.swing.JTextField[,67,53,142x25,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@1e1962d,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=5,columnWidth=0,command=,horizontalAlignment=LEADING]]
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:204)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)
... 26 more